[英]How to not select Included Table in EF Core
I have two table that related with each other我有两个相互关联的表
public class EMPEmployee
{
[Key]
public int? Id { get; set; }
[Required]
[StringLength(100)]
public string? FirstName { get; set; }
[Required]
[StringLength(100)]
public string LastName { get; set; }
public virtual ICollection<InOutRequestLeave>? InOutRequestLeave { get; set; }
}
public class InOutRequestLeave
{
[Key]
public int? Id { get; set; }
[Required]
[StringLength(10)]
public string RequestDate { get; set; } = "";
[Required]
[StringLength(10)]
public string FromDate { get; set; } = "";
[Required]
[StringLength(10)]
public string ToDate { get; set; } = "";
[Required]
public int LeaveDay { get; set; }
public virtual EMPEmployee? EMPEmployee { get; set; }
}
And this is my lambda query for get all data from InOutRequestLeave for any employee in C# Asp.Net Core project:这是我的 lambda 查询,用于从 InOutRequestLeave 获取 C# Asp.Net Core 项目中任何员工的所有数据:
public async Task<List<InOutRequestLeave>> GetUserAllAsync(EMPEmployee employee)
{
return await _uw.GetRepository<InOutRequestLeave>().GetAll(x.EMPEmployee.Id == employee.Id).Include(x => x.EMPEmployee).ToListAsync();
}
And this is my Api output using json:这是我的 Api output 使用 json:
{
"requestDate": "1401/05/01",
"fromDate": "1401/05/01",
"toDate": "1401/05/01",
"leaveDay": 1,
"empEmployee": {
"firstName": "test",
"lastName": "testy",
}
I want to remove "empEmployee" select from output using lambda after including我想在包括
You can define a new model for this query.您可以为此查询定义一个新的 model。 By creating a data transform object, you can obtain this data set you need with the help of a method.通过创建数据变换 object,您可以借助方法获得所需的数据集。 Thus, you will embody your query.因此,您将体现您的查询。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.