This is a migrated thread and some comments may be shown as answers.

AsTransient() is missing for DateTime property

5 Answers 67 Views
Development (API, general questions)
This is a migrated thread and some comments may be shown as answers.
This question is locked. New answers and comments are not allowed.
Markus
Top achievements
Rank 1
Markus asked on 26 Apr 2012, 09:50 AM
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


5 Answers, 1 is accepted

Sort by
0
PetarP
Telerik team
answered on 27 Apr 2012, 03:36 PM
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!
0
Trevor
Top achievements
Rank 1
answered on 15 Apr 2013, 04:57 PM
Can I use the default mapping, and still specify a DateTime as Transient?
0
PetarP
Telerik team
answered on 16 Apr 2013, 03:11 PM
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 >>
0
Trevor
Top achievements
Rank 1
answered on 16 Apr 2013, 09:31 PM
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?

0
PetarP
Telerik team
answered on 19 Apr 2013, 11:29 AM
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 >>
Tags
Development (API, general questions)
Asked by
Markus
Top achievements
Rank 1
Answers by
PetarP
Telerik team
Trevor
Top achievements
Rank 1
Share this question
or