当我调用fetchGroups
方法时,我在
var result = gp.Cast<Jobs>().ToList();
我对linq很新。有任何建议请。
型号:
public List<Jobs> fetchGroups(decimal Trans_ID, decimal Job_Id)
{
var gp = (from Trans_Mast in r2ge.Transcription_Tracker
where Trans_Mast.Transcription_Id == Trans_ID &&
Trans_Mast.Entity_Id == Job_Id
select
new
{
Trans_Mast.Group_Name
}).Distinct();
var result = gp.Cast<Jobs>().ToList();
return result;
}
public class Job
{
List<Room> room = new List<Room>();
public int totalImage { get; set; }
public int totalAudio { get; set; }
public int Transcribe_Rooms { get; set; }
public DateTime DataTime { get; set; }
public DateTime CreatedOn { get; set; }
public DateTime LastModified { get; set; }
}
答案 0 :(得分:1)
问题的答案是
List<string> gp = (from Trans_Mast in r2ge.Transcription_Tracker
where Trans_Mast.Transcription_Id == Trans_ID && Trans_Mast.Entity_Id == Job_Id && Trans_Mast.Group_Name != null
select new
{
Trans_Mast.Group_Name
}).AsEnumerable().Select(dr => dr.Group_Name).Distinct().ToList();