lundi 17 octobre 2016

Create Expression

there exists a nice database called LiteDB. What I find inconvenient is an absence of attributes for specifying the relation type (value/reference) between entities, though LiteDB provides fluent interface for hardcoding it (details: http://ift.tt/2dVxdtY). I am lazy guy and don't want always update this hardcoded relations to follow the changes in my data model. So I decided to realize the runtime discovery of the data model entities with the properties attributed by DbRef (my custom attribute). Unfortunately, I am stuck a little with creating the

Expression<Func<T,K>> 

in the .Net runtime... for providing it in the following call (first parameter):

BsonMapper.Global.Entity<Order>().DbRef(x => x.Customer, "customers"); 

Types T and K are given in runtime as instances of System.Type (here in example: T - Order, K - Customer).

I'll really appreciate if you guys give me some hints on how to instantiate

Expression<Func<T,K>> 

in .Net runtime in order to provide it to ...DbRef(...) function.





Aucun commentaire:

Enregistrer un commentaire