如何將以下linq轉換爲sql轉換爲lambda表達式。謝謝。將Linq查詢轉換爲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; }
}
爲什麼你需要這樣做? – sr28
你在詢問之前曾經嘗試/研究過什麼?這可以幫助你:https://codeblog.jonskeet.uk/2011/01/28/reimplementing-linq-to-objects-part-41-how-query-expressions-work/ –
閱讀[問]並分享你的研究走向實際的錯誤。沒有錯誤,我們不能做太多事情。 – CodeCaster