我得到如下错误
cannot convert from 'System.Collections.Generic.IEnumerable AnonymousType#1' to 'System.Collections.Generic.IEnumerable WebUI.DataModels.CandidateGeographiesAttributes'
我的代码如下
//Able to get result from SP here
List obj_Candidate_Geographies_List =
DBEntity.sp_GetCandidateEntityDataByFunctionTypeIdAndLevel(
Convert.ToInt32(FunctionTypeEnum.Geography),
Convert.ToInt32(EntityLevel.Undefined)
).ToList();
//Not able to convert to predefined model here
IQueryable obj_Candidate_Geographies_Attributes_List =
(from c in DBEntity.Candidates.ToList()
join p in DBEntity.vw_Candidate_AttributesNew.ToList()
on c.CandidateId equals p.CandidateId
join q in obj_Candidate_Geographies_List
on c.CandidateId equals q.CandidateId
select new
{
CandidateId = c.CandidateId,
FirstName = q.FirstName,
LastName = q.LastName,
GeographyId = q.GeographyId,
GeographyName = q.GeographyName,
SkillId = p.SkillId,
SkillName = p.SkillName,
CreatedOn = c.CreatedOn,
ModifiedOn = c.ModifiedOn
}
);
//Predefined Model
public class CandidateGeographiesAttributes
{
public int CandidateId { get; set; }
public string FirstName { get; set; }
public string LastName { get; set; }
public int GeographyId { get; set; }
public string GeographyName { get; set; }
public int SkillId { get; set; }
public string SkillName { get; set; }
public DateTime CreatedOn { get; set; }
public DateTime ModifiedOn { get; set; }
}
任何人都可以帮助我如何将 linq 结果转换为预定义数据模型的列表。