【发布时间】:2016-09-06 08:45:54
【问题描述】:
如何将以下 linq to sql 转换为 lambda 表达式。谢谢。
var existing = (from a in db.sms_imported_trn_code
where !db.sms_description.Any(m => m.trn_code == a.trn_code)
select new { trn_code = a.trn_code }).ToList();
编辑:
我尝试了以下查询,但它给了我一个错误。请查看下面的图片。
我的模型类如下
public class sms_imported_trn_code
{
public int id { get; set; }
public string trn_code { get; set; }
List<sms_imported_trn_code> sms_import_list { get; set; }
}
}
public class sms_description
{
public int id { get; set; }
public string trn_code { get; set; }
public string Description { get; set; }
[DisplayFormat(DataFormatString = "{0:MMM-dd-yyyy}", ApplyFormatInEditMode = true)]
public DateTime create_date { get; set; }
public string created_by { get; set; }
}
【问题讨论】:
-
为什么需要这样做?
-
在询问之前您尝试/研究了什么?这可能会对您有所帮助:codeblog.jonskeet.uk/2011/01/28/…
-
阅读How to Ask 并分享您对实际错误的研究。如果没有错误,我们将无法做很多事情。
-
现在他已经为我的解决方案添加了
error。你现在可以帮我吗? :D @CodeCaster -
顺便说一句,你为什么使用 Any (!db.sms_description.Any) 的反面,而不是
All?
标签: c# entity-framework lambda linq-to-sql