//[VirtualField] public string OwnerName { get { return Owner.Name; } } I would like to use this in Select/Where
this should be equivalent to
But if I have dozen linked enities it will be ugly. May be it could be expression parser to transform accessing to non persisted property to mapped one? This thread was imported from our support forum. The original discussion may contain more detailed answer. |
Alex (Xtensive) wrote:This is already possible. See: psulek wrote:
And can you DO4 guys think about implement such feature with attribute [VirtualField] where it will convert method of this get_OwnerName into Func<expression> with postsharp in behind of build process. To be fully transparent for us, we just mark property like this OwnerName with attribute [VirtualField] and postsharp does magic for us. Can be this possible or not? Alex (Xtensive) wrote:This must be possible only if we know what kind of logic must be inside OwnerName property getter. But we don't - all we know is its name and type. The logic is hard-coded in IL, and it's impossible (w/o such tool as Reflector, and if there are many statements - even with it) to convert it C# Expression tree, that can be transformed to the one used by DO4 during LINQ query translation. mahdness wrote:I did something similar in DO 3.9 for fill descriptors (analog of Prefetch in this case). OwnerName property would be marked with VirtualFieldAttribute("Owner.Name") (it would be nice if we could handle more complicated cases such as Person.Age being marked with VirtualField("DateTime.Now - DateOfBirth")] Anyway, if you cached these during domain build process and created LINQ rewriters for them (as well as prefetch processors), that would be cool. Just a thought And this topic in Manual: http://dataobjectsdotnet.googlecode.com ... ranslation If such an attribute has a property allowing to specify an expression as string, this is really possible. So we'll take this into account and consider implementing this in future. |