Entitty框架显示该项目不止一个 [英] Entitty framework show the item more than one
本文介绍了Entitty框架显示该项目不止一个的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
您好,
我尝试使用此代码,但它向我显示的项目不止一个
我该如何解决这个问题?
var element =(来自 h ent.REPORTHEADERs
join d ent.REPORTDETAILS中的code-keyword>等于d.FIS_NO
选择 new
{
h.SUBE_ID,
h.FIS_NO,
h.TERAZI_NO,
h.TERAZI_REYON_NO,
d.URUN_NO ,
d.BIRIM_FIYAT,
h.SATICI_NO,
h.MUSTERI_NO,
h.FIS_ADET,
h.FIS_AGIRLIK,
h.TUTAR,
h.IPTAL,
h.ILK_ISLEM_TARIHI,
h。 SON_ISLEM_TARIHI,
h.FIS_SAYISI,
h.TERAZI_ADIIP
})。ToList();
我尝试了什么:
我试图评论连接部分及其工作完美然而我添加连接部分我得到相同的项目3次
解决方案
您可以尝试:
。ToList()。FirstOrDefault();
在ToList()方法的末尾,以便在寻找单个值返回时获取满足该语句的第一个元素。
Hello,
I try to use this code however it show me the item more than one
how can i fix this?
var element = (from h in ent.REPORTHEADERs
join d in ent.REPORTDETAILS on h.FIS_NO equals d.FIS_NO
select new
{
h.SUBE_ID,
h.FIS_NO,
h.TERAZI_NO,
h.TERAZI_REYON_NO,
d.URUN_NO,
d.BIRIM_FIYAT,
h.SATICI_NO,
h.MUSTERI_NO,
h.FIS_ADET,
h.FIS_AGIRLIK,
h.TUTAR,
h.IPTAL,
h.ILK_ISLEM_TARIHI,
h.SON_ISLEM_TARIHI,
h.FIS_SAYISI,
h.TERAZI_ADIIP
}).ToList();
What I have tried:
I tried to comment the join part and its work perfect however i add the join part i get same item 3 times
解决方案
You could try:
.ToList().FirstOrDefault();
at the end of the ToList() method in order to get the first element that satisfies the statement if youre looking for a single value to come back.
这篇关于Entitty框架显示该项目不止一个的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文