c# - linq query that selects any object in the model -
edit
understand trying give example
suppose used entity framework generate multiple tables. have mydbentities objects (client, user, product, singer [attributes don't matter]). create method. method gets object parameter + mydbentities. object client, user, product, singer. in method have query given object return list of object. trying create method still trying either linq or sql in vain far
update
tried this, works, not way want to. understand me check code below.
viewbag.ok = libmethods.get_all(mydbentities, "client"); //params = entity & string
this how can method below method
public static object get_all (mydbentitiesce, string given_entity_type) { if (given_entity_type.equals("client")) { var get_all = clt in ce.client select clt; return get_all.tolist().first(); } else if (given_entity_type.equals("product")) { var get_all = pdt in ce.product select pdt; return get_all.tolist().first(); } return null; }
as can see method checks object given , creates , returns list of objects of given_entity_type. here return first element because doing tests.
suppose add new object mydbentities
& call developer
have update method don't want want generic work on object give exists in mydbentities
. that's mean generic/dynamic.
would oftype query want? i'm not sure understand question, query filter list of objects given type.
Comments
Post a Comment