英文:
Getting Value for table_id
问题
我有2张表 SaleMaster
public class SaleMaster
{
public int Id { get; set; }
public List<Installments> Installments { get; set; }
}
public class Installments
{
public int Id { get; set; }
public decimal Amount { get; set; }
public DateTime Month { get; set; }
public bool IsPaid { get; set; }
}
现在我想获取所有待付款的分期付款,
但我还想包括来自分期付款表的 SaleMaster ID,以便我可以导航回去。
List<Installments> instalment = con.DbSetInstallments
.Where(x => x.Month < d && x.IsPaid == false)
.ToList();
现在我想从这个待付款分期付款列表中获取 SaleMaster。
英文:
I have 2 tables SaleMaster
public class SaleMaster
{
public int Id { get; set; }
public List<Installments> Installments { get; set; }
}
public class Installments
{
public int Id { get; set; }
public decimal Amount { get; set; }
public DateTime Month { get; set; }
public bool IsPaid { get; set; }
}
Now I want to get the all the Installments with pending due dates,
but I also want to include the SaleMaster ID from Installment table so I can navigate back.
List<Installments> instalment = con.DbSetInstallments
.Where(x => x.Month < d && x.IsPaid == false)
.ToList();
Now I want to take SaleMaster from this list of which Installments are due.
答案1
得分: 1
你可以在 Installments
中为 SaleMaster
添加一个关联属性:
public class Installments
{
// ...
public int SaleMasterId { get; set; }
public virtual SaleMaster SaleMaster { get; set; }
}
这样你就可以轻松访问 SaleMaster 的 Id
。
英文:
You can add a relational property to SaleMaster
in Installments
:
public class Installments
{
public int Id { get; set; }
public decimal Amount { get; set; }
public DateTime Month { get; set; }
public bool IsPaid { get; set; }
public int SaleMasterId { get; set; }
public virtual SaleMaster SaleMaster { get; set; }
}
This way you have easy access to the SaleMaster's Id
.
通过集体智慧和协作来改善编程学习和解决问题的方式。致力于成为全球开发者共同参与的知识库,让每个人都能够通过互相帮助和分享经验来进步。
评论