MemberInitExpression

37 views
Skip to first unread message

Toni Wenzel

unread,
Jun 24, 2016, 8:22:44 AM6/24/16
to re-motion Users
Hi there,

for the most times I'll select my objects using the common "select new {}" pattern resulting into an anonymous type.

But sometimes I want to instantiate an already existing type using "from a in source select new MyEntity() {Name = a.FirstName}"
Executing this I get an MemberInitExpression is not supported exception. I think the SQLBackend wants to translate this expression into SQL, but I only wants to retrieve the required columns and create the objects afterwards. 

How can I achieve to get this working? Any hints?

Fabian Schmied

unread,
Jun 24, 2016, 8:56:08 AM6/24/16
to re-moti...@googlegroups.com
Hi,

The SQL Backend needs to translate parts of MemberInitExpressions into SQL, after all it must select the columns referenced within the expression (FirstName, in your example). Unfortunately, this feature hasn't yet been implemented in the SQL Backend, see https://www.re-motion.org/jira/browse/RMLNQSQL-35.

Best regards,
Fabian

--
You received this message because you are subscribed to the Google Groups "re-motion Users" group.
To unsubscribe from this group and stop receiving emails from it, send an email to re-motion-use...@googlegroups.com.
To post to this group, send email to re-moti...@googlegroups.com.
Visit this group at https://groups.google.com/group/re-motion-users.
For more options, visit https://groups.google.com/d/optout.

Toni Wenzel

unread,
Jul 5, 2017, 2:13:28 AM7/5/17
to re-motion Users
Hi,

can you please give me just a few hints how to implement this?

Regards
Toni

Gordon Watts

unread,
Jul 6, 2017, 1:47:19 PM7/6/17
to re-moti...@googlegroups.com

Hi,

  I had to do something like this for my LINQ -> C++ back end. I ended up using an expression visitor that did the lifting. By the time it got called, relinq and others had moved the “new” of the tuple or custom object close to the de-reference. I’m not familiar with the SQL backend, but this might be useful:

 

                https://github.com/gordonwatts/LINQtoROOT/blob/master/LINQToTTree/LINQToTTreeLib/Expressions/ObjectPropertyExpressionVisitor.cs

 

  This also strikes me as a routine that could be made pretty generic and included in a utility tool kit with the library as many (but perhaps not all users) would be interested in using it.

 

 

Cheers,
Gordon.

Michael Ketting

unread,
Jul 7, 2017, 2:05:19 AM7/7/17
to re-motion Users
Hi Toni,

There's a thread about that on the dev-list: https://groups.google.com/forum/#!searchin/re-motion-dev/member$20init/re-motion-dev/dMIw3XTQWi0/xKFIbUgoPqIJ

The patch is still from back when this was all an SVN repository and there's some stuff missing in the patch (implementation-wise and with tests and code-style). But we do accept PRs so if you want to tackle that one :)

~Michael

PS: Sorry I didn't get to this sooner, for some reason the post didn't show up as unread in my google-groups window until yesterday :/

To unsubscribe from this group and stop receiving emails from it, send an email to re-motion-users+unsubscribe@googlegroups.com.
To post to this group, send email to re-motion-users@googlegroups.com.

Reply all
Reply to author
Forward
0 new messages