0

在使用实体框架的情况下,我想连接具有相同值的两个字段的表,但是字段用不同的数据类型标识。例如,有一个字段的数据类型是“Guid”,但在另一个表中关联的字段是“字符串”类型。我对实现目标感到困惑。有人可以给我一些想法吗?这是我的代码,emps.EmpGuid 是“Guid”数据类型,flowCode.Object 是字符串:

DbSet<tb_Emp_Manager_Zbdl> dbEmp = zbdlcontext.Emp_Manager;
DbSet<Tb_Corp_CompanyInfo_Zbdl> dbCompany = zbdlcontext.Corp_CompanyInfos;
DbSet<Tb_FlowCode_Zbdl> dbFlowCode = zbdlcontext.FlowCodes;
DbSet<Tb_Emp_Post_Zbdl> dbEmpPost = zbdlcontext.Emp_Post;
var query = from emps in dbEmp
            join companies in dbCompany on emps.CorpGuid equals companies.CorpUserGuid
            join flowCode in dbFlowCode on new { EmpGuid = emps.EmpGuid.ToString(), AreaCode = areaCode } equals new { EmpGuid = flowCode.ObjectId, AreaCode = flowCode.AreaCode } into jFlowCodes
            from flowCodes in jFlowCodes.DefaultIfEmpty()
            join post in dbEmpPost on emps.EmpGuid equals post.EmpGuid into jPosts
            from posts in jPosts.DefaultIfEmpty()
            select new tb_Emp_Manager()
                       {
                            EmpGuid = emps.EmpGuid,
                            AreaCode = emps.AreaCode,
                            FlowCode = flowCodes.FlowCode,
                            corpName = companies.CorpName
                       };
4

0 回答 0