fluent versioning and type mapping help, please

Discussion of open issues, suggestions and bugs regarding LinqConnect – Devart's LINQ to SQL compatible ORM
Post Reply
unclelem
Posts: 6
Joined: Tue 11 Aug 2015 17:01

fluent versioning and type mapping help, please

Post by unclelem » Tue 11 Aug 2015 17:15

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

MariiaI
Devart Team
Posts: 1472
Joined: Mon 13 Feb 2012 08:17

Re: fluent versioning and type mapping help, please

Post by MariiaI » Thu 13 Aug 2015 07:15

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.

unclelem
Posts: 6
Joined: Tue 11 Aug 2015 17:01

Re: fluent versioning and type mapping help, please

Post by unclelem » Thu 13 Aug 2015 14:07

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;};

MariiaI
Devart Team
Posts: 1472
Joined: Mon 13 Feb 2012 08:17

Re: fluent versioning and type mapping help, please

Post by MariiaI » Fri 14 Aug 2015 10:58

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;

unclelem
Posts: 6
Joined: Tue 11 Aug 2015 17:01

Re: fluent versioning and type mapping help, please

Post by unclelem » Fri 14 Aug 2015 15:02

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?

MariiaI
Devart Team
Posts: 1472
Joined: Mon 13 Feb 2012 08:17

Re: fluent versioning and type mapping help, please

Post by MariiaI » Wed 19 Aug 2015 06:02

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.

unclelem
Posts: 6
Joined: Tue 11 Aug 2015 17:01

Re: fluent versioning and type mapping help, please

Post by unclelem » Wed 19 Aug 2015 14:39

Thank you, this is all very helpful.

MariiaI
Devart Team
Posts: 1472
Joined: Mon 13 Feb 2012 08:17

Re: fluent versioning and type mapping help, please

Post by MariiaI » Fri 21 Aug 2015 06:17

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.

jszalay
Posts: 5
Joined: Thu 10 Sep 2015 18:53

Re: fluent versioning and type mapping help, please

Post by jszalay » Sat 12 Sep 2015 00:11

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.

MariiaI
Devart Team
Posts: 1472
Joined: Mon 13 Feb 2012 08:17

Re: fluent versioning and type mapping help, please

Post by MariiaI » Tue 15 Sep 2015 05:29

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.

Post Reply