English 中文(简体)
LINQ “on”条款的多重条件
原标题:LINQ multiple condition on "on" clause
  • 时间:2010-06-07 09:52:47
  •  标签:
  • linq

我对条款有多重条件提出疑问。

SELECT * 

 FROM   
       CATALOGITEM  with (nolock) INNER JOIN CATALOG with (nolock) ON
       CATALOGITEM.catalog_id = CATALOG.catalog_id and not(catalog.catalog_id = 21) AND NOT(catalog.catalog_id = 20)

       INNER JOIN PRODUCT with (nolock)  ON   
         CATALOGITEM.s_num = PRODUCT .s_num   
        LEFT OUTER JOIN PRODUCT_DETAIL with (nolock)  ON 
       PRODUCT_DETAIL.s_num = PRODUCT.s_num      
           WHERE
           (  
              CATALOGITEM.publish_code =  upd  OR  
              CATALOG_ITEM.publish_code =  ins  OR  
              PRODUCT.publish_code =  upd  OR  
              PRODUCT.publish_code =  ins   
           )  

       and
       (CATALOG.unit_id = bu.unit_id)

如何在LINQ中撰写。

请提出咨询意见。

最佳回答

认为你没有加入防止母婴传播方案?

无论如何,这应该让你们开始。

var query = (from ci in db.catalogitem
         join c in db.catalog on ci.catalog_id equals c.catalog_id
         join p in db.products on ci.s_num equals p.s_num
         join pd in db.productdetail on p.s_num equals pd.s_num into tempprods
         from prods in tempprods.DefaultIfEmpty()
         where !(c.catalog_id.Contains(21, 20))
         && (ci.publish_code.Contains( upd , ins )) ||
            (p.publish_code.Contains( upd , ins ))
         select ci)
问题回答

如果你想要保护(NOLOCK)的背心,我就在C#中使用了推广方法,





相关问题
IEnumerable to array of parameter

Using linq? and XML is there a way to convert this IEnumerable to a string array of the value parameter? List<string> idList = new List<string>(); foreach (XElement idElement in word....

linq query for tag system - search for multiple tags

I have two tables, Tags(tagid, postid, tagname) and posts(postid, name, ...) now i want to make a query that returns me all posts that have a generic amount of tags. like: i want all posts that have ...

Linq operations against a List of Hashtables?

I m working with a set of legacy DAO code that returns an IList, where each Hashtable represents the row of a dynamically executed SQL query. For example, the List might contain the following records/...

Linqy no matchy

Maybe it s something I m doing wrong. I m just learning Linq because I m bored. And so far so good. I made a little program and it basically just outputs all matches (foreach) into a label control. ...

How to filter duplicate list items

i have list of items IList with data that looks list this: GenId TestMode 1 0 1 1 3 0 3 1 4 NULL 2 NULL i want to remove the index ...

C# Grouping/Sorting a Generic List<> using LINQ

Im looking to group and sort a Generic List<>. I have a list of objects representing files and each of these objects has a FileName, FileType and FileDate property. FileType is defined as an ...

热门标签