Nullable int Property

Thread is closed for posting
3 posts, 0 answers
  1. Dmitry
    Dmitry avatar
    8 posts
    Member since:
    Oct 2012

    Posted 24 Jul 2013 Link to this post

    I use artifical API for mapping nullable field.
    prop = tableMappingConfig.HasArtificialPrimitiveProperty("Age", typeof(int));
    But Member with name "Age" in PersistentType did not generated Nullable Property.
    And when I'm trying to update field which contain "null"  value
    SELECT [id], net  FROM [dbo].[Kassa] WHERE id = 52
    id          net
    ----------- -----------
    52          NULL

    I'm getting exception
    Row not found: GenericOID@8ab3a1bd Kassa id=52\nUPDATE [Kassa] SET [net]=? WHERE [id] = ? AND [net]=?\n(set event logging to all to see parameter values).
    In sql profiller we see
    declare @p1 int
    set @p1=2
    exec sp_prepexec @p1 output,N'@p0 int,@p1 int,@p2 int',N'UPDATE [Kassa] SET [net]=@p0 WHERE [id] = @p1 AND [net]=@p2',@p0=1,@p1=52,@p2=0
    select @p1

    Why when using artifical Api property of CLR Type doesn't generated with nullable?


  2. Dmitry
    Dmitry avatar
    8 posts
    Member since:
    Oct 2012

    Posted 25 Jul 2013 Link to this post

    Problem was resolved.

    It was necessary to do so
    prop = tableMappingConfig.HasArtificialPrimitiveProperty("Age", typeof(int?))
  3. Jan Blessenohl
    Jan Blessenohl avatar
    707 posts

    Posted 25 Jul 2013 Link to this post

    Hello Dimitry,
    The IsNullable() defines the column type. The property in the artificial type is defined by the type itself.

    prop = tableMappingConfig.HasArtificialPrimitiveProperty("Age", typeof(int?));

    Jan Blessenohl
    OpenAccess ORM Q2 2013 brings you a more powerful code generation and a unique Bulk Operations support with LINQ syntax. Check out the list of new functionality and improvementsshipped with this release.

Back to Top