C#EF CF选择多个查询

时间:2013-09-21 12:02:21

标签: c# sql-server entity-framework ef-code-first

public class TempClass
{
    public int ID { get; set; }
    public int CountEntries { get; set; }
}

string sql = "select ID, count(*) as CountEntries from table1;select ID, count(*) as CountEntries from table2";

var result = _dbContext.Database.SqlQuery<TempClass>(sql).ToList<TempClass>(); ???

执行几个命令,可以使用EF Code First吗?或者你必须一次得到一个(上面的结果是2个SqlQueries。

1 个答案:

答案 0 :(得分:0)

我认为你可以使用这个:

var query = (from s in context.table1.Take(1)
             select new
             {
                 subSetA = context.tablw1.ToList(),
                 subSetB = context.tablw2.ToList(),
             })