tags:

views:

67

answers:

1

Hello Sir/Madam,

How to create a property that return TEntity object for dataContext.GetTable parameter. The example code shown below. Thank You.

public IQueryable<Order> FetchAll()
{
     dataContext.GetTable<MyTEntity>();//<==
}

protected Type MyTEntity //<==
{
    get { return Order; }
}
+1  A: 

You need to be more specific in what you are trying to do. By the looks of it you trying to implement some form of repository class. If you are looking to simply return a single order you need to supply an identifier i.e. something that you can use to find that particular order e.g.

public IQueryable<Order> FetchAll()
{     
    // you should probably be able to return dataContext.NameOfOrderTable here instead.
    return dataContext.GetTable<Order>();
}

protected Order GetOrder(int id)
{    
    // again you should be able to use dataContext.NameOfOrderTable here
    return dataContext.GetTable<Order>().SingleOrDefault(o => o.ID == id);
}
James