明显不在实体框架中工作

Lok*_*esh 3 c# entity-framework-6

获取文档列表的函数只有不同的...

public static List<DocumentTypeModel> GetUploadedDocumentsName(int TicketId)
{
    List<DocumentTypeModel> documents = new List<DocumentTypeModel>();
    using (var db = new UnitOfWork())
    {
        documents = db.tbl_TrnTicketDocument.Get(x => x.FK_TicketId == TicketId && x.IsActive == true).Select(s => new DocumentTypeModel()
        {
            DocumentTypeNameEnglish = s.tbl_MstDocumentType.DocumentTypeNameEnglish
        }).Distinct().ToList();
    }
    return documents;
}
Run Code Online (Sandbox Code Playgroud)

目前的结果是 -

在取消遗嘱/不遗嘱的情况下的宣誓书

在取消遗嘱/不遗嘱的情况下的宣誓书

分配信

分配信

死亡证明

死亡证明

租赁契约

租赁契约

申请人的照片身份

申请人的照片身份

占有信

占有信

已注册/未注册的遗嘱

已注册/未注册的遗嘱

Nav*_*dar 9

您可以使用groupby并选择第一个选项,如下所示:

List<DocumentTypeModel> documents = new List<DocumentTypeModel>();
using (var db = new UnitOfWork())
{
   documents = db.tbl_TrnTicketDocument.Get(x => x.FK_TicketId == TicketId && x.IsActive == true).Select(s => new DocumentTypeModel()
   {
   DocumentTypeNameEnglish = s.tbl_MstDocumentType.DocumentTypeNameEnglish
   }).ToList();

   documents = documents.GroupBy(x => x.DocumentTypeNameEnglish).Select(g => g.First());
}
Run Code Online (Sandbox Code Playgroud)