Linq中的多列检查

时间:2018-09-16 11:41:45

标签: sql sql-server linq

在linq中编写以下sql查询的好指南

SELECT DISTINCT
    Item.Id AS ItemId, Item.CatId, [Case].Id AS CaseId
    FROM [Item] WITH (NOLOCK)
    LEFT OUTER JOIN [Case] WITH (NOLOCK) ON [Case].Id = Item.CaseId
    LEFT OUTER JOIN [Cust] WITH (NOLOCK) ON [Case].CustId1 = Cust.Id OR 
       [Case].CustId2 = Cust.Id

我不明白如何在联接中包含CustId1和CustId2。

下面是没有CustId2的情况:

 var query = (from i in db.Item
              join c in db.Case on i.CaseId equals c.Id
              into joined
              from c in joined.DefaultIfEmpty()
              join cus in db.Cust on c.CustId1 equals cus.Id
              into cust

              from cus in cust.DefaultIfEmpty()
              select new
              {
                  Item=i,
                  Case = c,
                  Category = ct,
                  Pro = pr,
                  ZCatClass =zcc,
                  ZCatTyp = cct,
                  cust = cus
              }).OrderByDescending(d => d.Item.Id).ToList();

1 个答案:

答案 0 :(得分:0)

from sklearn.model_selection import KFold
import numpy as np

kf_test = KFold(n_splits=14)
test_x = np.random.rand(40)
pointer = 0
for item_t, item_v in kf_test.split(test_x):
    if pointer == 0:
        print(item_t.shape)
        print(item_v.shape)
        print(len(item_v) / 40)
    pointer += 1
pointer, test_x