我有以下情况。一个带有连接语句的linq查询:
public Object getMGM(int MEB_Id)
{
var unitOfWork = new DAL.Implementations.Entity_Framework.UnitOfWork<dbgmEntities>();
var queryRoles = from a in unitOfWork._ctx.MembrosMGM
join b in unitOfWork._ctx.Membros on a.MGM_Pai equals b.MEB_Id
where a.MGM_Filho == MEB_Id
select new { b.MEB_Nome, b.MEB_Id, a.MGM_Familiar };
return queryRoles;
}
queryRoles
在线程内运行。所以,我只需要将它作为一个对象返回。但我找不到一种方法来投射它并获得{ b.MEB_Nome, b.MEB_Id, a.MGM_Familiar }
选择。我尝试了以下代码,并在返回时设置了一个实体,它工作正常,但如果我在同一个 linq 查询中有超过 1 个实体,我不知道如何将其转换回:
//this one works fine if i have just one entity set (DAL.MembroResponsavel)
var queryMembroResponsaveis = ((IEnumerable)smartThreadPool.QueueWorkItem(x => editMeb.getMembroResponsavel(currentId)).Result).Cast<DAL.MembroResponsavel>().ToList();
谢谢。