0
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.

4

1 回答 1

0

i think you can use this :

var query = (from s in context.table1.Take(1)
             select new
             {
                 subSetA = context.tablw1.ToList(),
                 subSetB = context.tablw2.ToList(),
             })
于 2021-04-30T20:59:54.710 回答