本文介绍了林克加入哪里?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述


  • entity1 - ID,OwnerCode


    • entity2 - OwnerCode,DepartmentCode

    另外我有一些DepartmentCode

    Also I have some DepartmentCode

    现在我想得到这样的东西(sql语法):

    Now i want get something like this(sql syntax):

    Select e1.ID 
    from entity1 e1 
    join entity2 e2 on e1.OwnerCode = e2.OwnerCode and e2.DepartmentCode=7
    

    通过Linq

    我写道:

    var q = from e1 in entityes1 
            join e2 in entityes2 on e1.OwnerCode equals e2.OwnerCode ... 
    

    但是如何在这里插入DepartmentCode = 7

    But how insert DepartmentCode=7 here I don't understand.

    推荐答案

    这不是加入表格的一个因素,它是选择记录的一个因素,所以它应该是一个where子句:

    That's not really a factor in joining the tables, it's a factor in selecting records, so it really should be a where clause:

    var q = from e1 in entityes1
            join e2 in entityes2 on e1.OwnerCode equals e2.OwnerCode
            where e2.DepartmentCode == 7
            select e1.ID;
    
    var id = q.Single(); 
    

    这篇关于林克加入哪里?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

10-29 08:11