AsTransient() is missing for DateTime property

6 posts, 0 answers
  1. Markus
    Markus avatar
    40 posts
    Member since:
    Sep 2008

    Posted 26 Apr 2012 Link to this post

    In my model a have a few transient properties which I can mark as follows

    configuration.HasProperty( x => x.CalculatedProp).AsTransient();

    But if property is of type DateTime it is not possible, because DateTimePropertyConfiguration does not have a function AsTransient().

    How could I define a DateTime property as transient?
    Is it possible to ignore properties which are not explicitly mapped or automatically mark them as transient?

    Regards,
    Markus


  2. PetarP
    Admin
    PetarP avatar
    754 posts

    Posted 27 Apr 2012 Link to this post

    Hello Markus,

     It is possible to achieve that using the .MapType() method. Whenever you use the MapType method without specifying a lambda expression this would instruct our metadata reader that all properties in that types will be default mapped if no explicit mapping is specified. 
    If you however use a method like this:

    productConfiguration.MapType(p => new
               {
                   ProductId = p.Id,
                   ProductName = p.Name,
                   Discontinued = p.Discontinued,
                   CategoryId = p.CategoryId
               }).ToTable("Products");
    Only the Id,Name,Discontinued and CategoryId properties will receive default mapping unless other is not specified. All properties that are not mentioned in this lambda expression and do not have an explicit mapping provided with the HasProperty method will be regarded as transient.
    The last possibility is to use this method with an empty lambda like this:
    productConfiguration.MapType(x => new { }).ToTable("Product");
    This would mean that no properties will receive default mapping and all will be considered to be transient unless explicit mapping is provided via the HasPropertyMethod.
    I hope this was helpful to you. All the best,
    Petar
    the Telerik team
    Follow @OpenAccessORM Twitter channel to get first the latest updates on new releases, tips and tricks and sneak peeks at our product labs!
  3. DevCraft banner
  4. Trevor
    Trevor avatar
    7 posts
    Member since:
    Jul 2012

    Posted 15 Apr 2013 Link to this post

    Can I use the default mapping, and still specify a DateTime as Transient?
  5. PetarP
    Admin
    PetarP avatar
    754 posts

    Posted 16 Apr 2013 Link to this post

    Hi Trevor,

     With the latest release of OpenAccess it is possible to specify .AsTransient() on properties of type DateTime.

    Regards,
    Petar
    the Telerik team
    Using Encrypted Connection Strings with Telerik OpenAccess ORM. Read our latest blog article >>
  6. Trevor
    Trevor avatar
    7 posts
    Member since:
    Jul 2012

    Posted 16 Apr 2013 Link to this post

    We have version 2013.1.219.3 and I am unable to specify AsTransient() on any DateTime properties. If I add the AsTransient() to my configuration, it says "Cannot resolve symbol 'AsTransient".

    It does, however, let me specify other types as Transient.

    Is there something else I'm missing here?

  7. PetarP
    Admin
    PetarP avatar
    754 posts

    Posted 19 Apr 2013 Link to this post

    Hello Trevor,

     The version you are using is not our latest internal build. You should be able to see the internal build under your downloads if you have downloaded the Q1 release from 2013 through our site.

    All the best,
    Petar
    the Telerik team
    Using Encrypted Connection Strings with Telerik OpenAccess ORM. Read our latest blog article >>
Back to Top
DevCraft banner