如何在sql
中编写以下Linq to Entities
?
select * from LanguageApplicationResource as outside
where LanguageId = 130 and
LastUpdatedOn < (select LastUpdatedOn from LanguageApplicationResource
where LanguageId = 75 and
ApplicationResourceId = outside.ApplicationResourceId)
我尝试了这个,但它用Unable to create a constant value of type 'xxxx'
轰炸了,这是有道理的,但我无法弄清楚Linq to Entities
方式。
var pendingList = LanguageApplicationResourceRepo.Table.Where(a => a.LanguageId == language.LanguageId &&
a.LastUpdatedOn < LanguageApplicationResourceRepo.Table.Where(b => b.LanguageId == defaultLanguage.LanguageId &&
b.ApplicationResourceId == a.ApplicationResourceId).FirstOrDefault().LastUpdatedOn).ToList();
答案 0 :(得分:0)
试试这个:
var query = dbContext.LanguageApplicationResource
.Where(u => LanguageId == 130 &&
dbContext.LanguageApplicationResource
.Where(t => t.LanguageId == 75 &&
t.ApplicationResourceId = u.ApplicationResourceId)
.Take(1)
.All(t => u.LastUpdatedOn < t.LastUpdatedOn)
)
.ToList();