如何使用表达式树生成以下内容...
var people = context.Set<Person>();
var transactions = context.Set<FinancialTransaction>();
var dataview = people.Where( p => p.LastName == "Smith" );
var selection = dataview
.Select( p => new
{
FirstName = p.FirstName,
LastName = p.LastName,
LastTransaction =
transactions
.Where( t => t.AuthorizedPersonId == p.Id )
.Max( t => t.TransactionDateTime )
} );
gReport.AutoGenerateColumns = true;
gReport.DataSource = selection.ToList();
gReport.DataBind();
Run Code Online (Sandbox Code Playgroud)
我正在尝试使用Ethan Brown 在这里提供的LinqRuntimeTypeBuilder解决方案,但在如何为LastTransaction子查询创建表达式以及如何将查询绑定到GridView方面苦苦挣扎.
这就是我到目前为止......
var people = context.Set<Person>();
var transactions = context.Set<FinancialTransaction>();
var dataview = people.Where( p => p.LastName == "Smith" …Run Code Online (Sandbox Code Playgroud) c# linq-to-entities entity-framework webforms expression-trees