我正在使用Linq使用Entity Framework来查询MySQL数据库,如下所示 –
var query = from c in subQuery
select new
{
Client = c.Client,
GlobalList = c.GlobalList,
Book = (from book in context.Books
where book.c_clt_id == c.Client.c_clt_id
select book)
};
var totalSearch = query.ToList();
现在我想将totalSearch作为参数传递给另一个方法.请帮帮我怎么做?
解决方法:
您还可以使用C#动态关键字.当然,它反射慢,类型不安全.例如:
void SomeMethod(dynamic d)
{
Console.WriteLine(d.Client);
Console.WriteLine(d.GlobalList.Count);
}