mardi 4 août 2015

C# reflection and Func

I have 3 classes, each have same function names:

class A {Func<sampleobject,bool> alpha = c=>c.some1 == something;Func<object,bool> beta= c=>c.some1 == something;}
class B {Func<sampleobject,bool> alpha = c=>c.some1 == something;Func<sampleobject,bool> beta= c=>c.some1 == something;}
class C{Func<sampleobject,bool> alpha = c=>c.some1 == something;Func<sampleobject,bool> beta= c=>c.some1 == something;}

I have a factory that will get me the proper class. there's also another property that will determine which function of the class gets called.

dbcontext.sampleobjects.where(Factory(class).ReflectionFunction(memberName));

I was able to use reflection to get the member name via:

var prop = this.GetType().GetMember("alpha");

I just don't know how to use this or what to call to be able to be used in the "WHERE" statement like if I would call it directly.

dbcontext.sampleobjects.where(instanceofA.alpha);



via Chebli Mohamed

Aucun commentaire:

Enregistrer un commentaire