Hello,
I am using the entity framework model to query my database and have put in a few views that I would like to use that all have the same query parameters. Rather than write a big list of case-switch statements I am wondering how to do this programmatically by passing through the view object as a parameter to my main method. In sql I would do this like:
public void Tables(string TableName)
{
using(EntityModel entity = new EntityModel()){
string sql = "select * from " + TableName;
etc....
}
However I just can't see how to do a similar thing with the entity framework model i.e.
public void Tables(Type TableName)
{
using(EntityModel entity = new EntityModel()){
ObjectQuery<Users> oq = new ObjectQuery<Users>("EntityModel.Users", EntityModel);
var q = (from p in oq select p);
}
That's fine if you know what type of table or view you need (i.e. Users), but you can't pass a type as a parameter because ObjectQuery can't accept variables, typeof() or anything that isn't hard-coded. Anyone have any ideas if this is at all possible?