Entity framework 4 如何从列表中获取不同的值

Entity framework 4 如何从列表中获取不同的值,entity-framework-4,linq-to-entities,Entity Framework 4,Linq To Entities,我有一个从Linq到实体查询生成的列表。其中,我需要基于BibId获取唯一记录。我已尝试更改查询,但无法基于bibibid获取唯一记录 查询 aa.NewBibContentsModel = (from x in db.BibContents where (x.TagNo == "245" && x.NormValue == aa.CurrentTitle) || (x.TagNo == "020" &

我有一个从Linq到实体查询生成的列表。其中,我需要基于
BibId
获取唯一记录。我已尝试更改查询,但无法基于
bibibid
获取唯一记录

查询

aa.NewBibContentsModel = (from x in db.BibContents

                                      where (x.TagNo == "245" && x.NormValue == aa.CurrentTitle) || (x.TagNo == "020" && x.NormValue == aa.CurrentISBN) || (x.TagNo == "022" && x.NormValue == aa.CurrentISBN)
                                      select new
            {
                BibId = x.BibId,
                Title = (from a in db.BibContents where a.BibId == x.BibId && a.TagNo == "245" orderby a.Id ascending select a.NormValue),
                //Tit = (from a in db.BibContents where a.BibId == line.BibId && a.TagNo == "245" && a.Sfld == "a" select a.NormValue).FirstOrDefault(),
                Author = (from a in db.BibContents where a.BibId == x.BibId && splitted.Contains(a.TagNo) && a.NormValue != null select a.TagNo).FirstOrDefault(),
                ISBN = (from a in db.BibContents where a.BibId == x.BibId && a.NormValue != null && (a.TagNo == "020" || a.TagNo == "022") orderby a.Id ascending select a.NormValue)
            }).AsEnumerable().Select(x => new BibContentsModel
            {
                BibId = x.BibId,
                Title = string.Join(" ", x.Title),
                Author = string.Join(" ", (from a in db.BibContents where a.BibId == x.BibId && a.TagNo == x.Author orderby a.Id select a.NormValue)),
                ISBN = string.Join(" ", x.ISBN)
            }).ToList();
对此问题的任何帮助都将不胜感激


谢谢

大家都知道你想要达到的目标是与众不同的。它有一个功能。语法如下所示:

(从db.BibContentsNo==“022”中的x开始)
... // 你的问题
}).可计算的()
.DistinctBy(x=>x.bibibid)//