I have a type which is stored in an Entity
table.
I want to get all records by type.
My method like this :
public void read(Type tablename)
{
// read data in context by type
}
I use this code but it doesn't work :
var test = new CmsContext().Set(_tableName);
Query will not execute until you use it's results, for example, by enumerating them to a list.
using System.Linq;
...
using(var ctx = new CmsContext())
{
var allEntitiesInSet = ctx.Set(_tableName).ToList();
}
You can read about "lazy execution" of queries here: https://msdn.microsoft.com/library/bb738633(v=vs.100).aspx
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.