实体框架调用函数将 id 更改为名称
从此代码中收到的 DriverId 将是一个数字。
protected void Page_Load(object sender, EventArgs e)
{
OrderDataRepository rep = new OrderDataRepository();
var results = rep.GetAllOrderData().
GroupBy(o => o.DRIVER_ID).
Select(g =>
new
{
DriverId = g.Key,
OrderCount = g.Count(),
OrderCountWhereNameIsNotNull =
g.Count(o => o.RECEIVE_NAME != null)
}).ToList();
DataViewer.DataSource = results;
DataViewer.DataBind();
}
我需要将此 DriverId 编号更改为名称 - 因此我需要调用另一个名为 get
的函数并接收名称。
public User Get(long userId)
{
return GetQuery().Single(x => x.Id == userId);
}
公共用户调用一个实体“用户”,该实体具有“id”(即驱动程序 ID)和“名称”。我需要名字。
The DriverId which will be received from this code will be a number.
protected void Page_Load(object sender, EventArgs e)
{
OrderDataRepository rep = new OrderDataRepository();
var results = rep.GetAllOrderData().
GroupBy(o => o.DRIVER_ID).
Select(g =>
new
{
DriverId = g.Key,
OrderCount = g.Count(),
OrderCountWhereNameIsNotNull =
g.Count(o => o.RECEIVE_NAME != null)
}).ToList();
DataViewer.DataSource = results;
DataViewer.DataBind();
}
I need to change this DriverId number to a name - so I need to call another function called get
and to receive a name.
public User Get(long userId)
{
return GetQuery().Single(x => x.Id == userId);
}
public user get calling an entity "user" which has "id" which is the driverid and "name". I need the name.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
这行得通吗?
Would this work?