Page 1 of 1
fluent versioning and type mapping help, please
Posted: Tue 11 Aug 2015 17:15
by unclelem
I am attempting to implement a fluent mapping of our existing C# class hierarchy (in order to avoid changing the classes being mapped), but I seem to be unable to mark the property with the "IsVersion()" tag - the method seems to simply not exist in the property hierarchy . What Am I doing wrong here?
Also we have many complex nested data structures which are never searched, that we wish to simply serialize and store a text value for (and deserialize upon rehydration). Is there any way via mapping (e.g. by means of a lambda expression) to map the data being stored/retrieved other than implementing a hidden member and using custom accessors.
for example
public HashSet<MyClass> member1;
it would be nice if the fluent mapper could be told to take the actual value of member1 and transform it via a call to my code and store the resulting string in the DB column. Similarly in reverse upon fetching the object.
Thanks
Re: fluent versioning and type mapping help, please
Posted: Thu 13 Aug 2015 07:15
by MariiaI
unclelem wrote:unable to mark the property with the "IsVersion()" tag
There is .IsRowVersion() method when working with the fluent mapping approach, however, it is available only for the binary properties. For example:
Code: Select all
builder.Entity<Class1>()
.Property(p => p.Property2)
.NotNullable().IsRowVersion()
.ServerDataType(@"varbinary(MAX) NOT NULL");
unclelem wrote:Is there any way via mapping (e.g. by means of a lambda expression) to map the data being stored/retrieved other than implementing a hidden member and using custom accessors.
Unfortunately, there is no such possibility. You can add properties of the primitive types and make all the necessary conversions in getters/setters.
Re: fluent versioning and type mapping help, please
Posted: Thu 13 Aug 2015 14:07
by unclelem
MariiaI wrote:There is .IsRowVersion() method when working with the fluent mapping approach, however, it is available only for the binary properties. For example:
CODE: SELECT ALL
builder.Entity<Class1>()
.Property(p => p.Property2)
.NotNullable().IsRowVersion()
.ServerDataType(@"varbinary(MAX) NOT NULL");
Then, using the fluent method, how do you associate this with an integer, long or datetime column so that it can be updated on a trigger, as is done with the annotational method in the documentation example? Or are you saying that this is not possible with the fluent method?
e.g. What is the fluent equivalent of
[Column(Name = "RowVersion", CanBeNull= false, IsVersion = true, DbType = "BIGINT(22) NOT NULL", AutoSync = always, DbGenerated = true)]
public long RowVersion {get; set;};
Re: fluent versioning and type mapping help, please
Posted: Fri 14 Aug 2015 10:58
by MariiaI
unclelem wrote:Then, using the fluent method, how do you associate this with an integer, long or datetime column so that it can be updated on a trigger, as is done with the annotational method in the documentation example?
Unfortunately, there is no such possibility for now. However, we will implement this functionality and inform you about the results as soon as possible.
Some useful information:
https://www.devart.com/linqconnect/docs ... ation.html
https://www.devart.com/linqconnect/docs ... pping.html
Please also try using this code:
Code: Select all
var property = builder
.Entity<MyClass>()
.Property(e => e.RowVersion);
((IPropertyConfiguration)property).IsRowVersion = true;
Re: fluent versioning and type mapping help, please
Posted: Fri 14 Aug 2015 15:02
by unclelem
Thank you for the quick assistance. I will try that as soon as I can.
Is it possible to mix both fluent and annotational methods? e.g. define some properties as annotations in the class, and then supplement them programmatically using fluent methodology? Or define some classes annotationally, and others using fluent methodology?
Re: fluent versioning and type mapping help, please
Posted: Wed 19 Aug 2015 06:02
by MariiaI
Is it possible to mix both fluent and annotational methods?
It is not supported in LinqConnect directly. However, you can implement this via fluent mapping conventions:
https://www.devart.com/linqconnect/docs ... tions.html
https://www.devart.com/linqconnect/docs ... tions.html
We are sending you a small sample project to the e-mail address you have provided in your forum profile. Please check that the letter is not blocked by your mail filter.
The sample shows a simple way to implement this, you can modify and extend it in the way, that is suitable for your scenario.
Then, using the fluent method, how do you associate this with an integer, long or datetime column so that it can be updated on a trigger, as is done with the annotational method in the documentation example?
We have implemented this functionality. The changes will be available in the next public build of LinqConnect which we plan to release soon. We will post here when the corresponding build is available for download.
Re: fluent versioning and type mapping help, please
Posted: Wed 19 Aug 2015 14:39
by unclelem
Thank you, this is all very helpful.
Re: fluent versioning and type mapping help, please
Posted: Fri 21 Aug 2015 06:17
by MariiaI
The possibility to use .IsRowVersion() method for properties with non-binary data types when using the fluent mapping approach is added.
New build of LinqConnect 4.5.816 is available!
It can be downloaded from
http://www.devart.com/linqconnect/download.html (trial version) or from Registered Users' Area (for users with active subscription only).
For more information, please refer to
http://forums.devart.com/viewtopic.php?f=31&t=32325.
Re: fluent versioning and type mapping help, please
Posted: Sat 12 Sep 2015 00:11
by jszalay
Could you please send me the example project that demonstrates how to mix fluent mapping with attribute-annotation mapping? Thanks. Some of my entities are mapped with attribute-annotations, some other entities are mapped with fluent.
Re: fluent versioning and type mapping help, please
Posted: Tue 15 Sep 2015 05:29
by MariiaI
We've sent you a small sample project to the e-mail address you have provided in your forum profile. Please check that the letter is not blocked by your mail filter.
The sample shows a simple way to implement mixed approach, you can modify and extend it in the way, that is suitable for your scenario.