这是我的 Linq 查询。这工作正常。问题是如果任何人在表中没有姓氏,则该行不会显示在结果中。我希望如果有人没有姓氏,那么它将是 User_Name= First Name +""。
var ShowFiles = from cm in db.Contact_Masters
join ta in db.Topic_Accesses on cm.Contact_ID equals ta.Contact_ID
join RelMess in db.Rel_Topics_Messages on ta.Topic_ID equals RelMess.Topic_ID
join Messages in db.Messages on RelMess.Message_ID equals Messages.Message_ID
join Files in db.Files on Messages.Message_ID equals Files.Message_ID
join FileType in db.Lkup_Files_Extensions on Files.TypeID equals FileType.TypeID
join FileVersion in db.File_Versions on Files.File_ID equals FileVersion.File_ID
join pcf in db.Contact_Personals on Messages.Contact_ID equals pcf.Contact_ID
where pcf.Personal_Type == new Guid("30102333-2104-40D7-8913-DC9048225D12") // Personal_Type = First Name ID
join pcl in db.Contact_Personals on Messages.Contact_ID equals pcl.Contact_ID
where pcl.Personal_Type == new Guid("9058F268-B707-4B0A-86E5-26E83A4BC1F5") // Personal_Type = Last Name ID
where cm.Contact_ID == new Guid(ContactID) && ids.Contains(RelMess.Topic_ID)// parameters
&& FileVersion.IsActive == true && Messages.IsActive == true && FileVersion.Version_ID == (from FileV in db.File_Versions
where FileV.File_ID == Files.File_ID
&& FileV.Message_ID == Messages.Message_ID
&& FileV.IsActive == true
select FileV.Version_ID).Max()
select new
{
File_Name = Convert.ToString(Files.File_Name),
Version_ID = Convert.ToString(FileVersion.Version_ID),
File_Size = Convert.ToString(FileVersion.File_Size),
Created = Convert.ToString(FileVersion.Created),
Type = FileType.Type,
File_URL = FileVersion.File_URL,
File_ID = Convert.ToString(FileVersion.File_ID),
User_Name = pcf.Value + " " + pcl.Value
};
谢谢纳希德
_