如何做左边连接lambda

时间:2015-02-08 10:06:01

标签: linq entity-framework lambda

    var item= (from t1 in _dbEntities.PurchaseSales
                join t2 in _dbEntities.ItemTypes on t1.ItemTypeID equals t2.ID
                where t2.ID.Equals(null)
               select t2).ToList();

怎么做左连接呢

1 个答案:

答案 0 :(得分:0)

使用DefaultIfEmpty

var item= (from t1 in _dbEntities.PurchaseSales
                join t2 in _dbEntities.ItemTypes on t1.ItemTypeID equals t2.ID into t
                from l in t.DefaultIfEmpty()
                where l == null
               select t1).ToList();