这些是我的疑问:
var originals = (from x in db1.MyStrings select x).ToList();
var translations = (from x in db2.MyTranslations.Where(x => x.language_id == languageId)
join y in originals
on x.original_id equals y.Id into joined
from j in joined.DefaultIfEmpty()
select new { x.language_id, x.translation, j.Content, j.Id }).ToList();
我在两个不同的数据库中有两个表。我希望获得所有原始字符串并将其与翻译联系起来(如果有的话)。因此列表与db1中的原始字符串表的大小相同。 MyStrings存储原始字符串,MyTransaltions存储翻译。
我现在得到的错误是:无法创建类型' MyString'的常量值。在此上下文中仅支持原始类型或枚举类型。
答案 0 :(得分:0)
试试以下是否有效,如果问题是相同的,我只面对一次。
var translations = (from y in originals
join x in db2.MyTranslations.Where(x => x.language_id == languageId)
on x.original_id equals y.Id into joined
from j in joined.DefaultIfEmpty()
select new { x.language_id, x.translation, j.Content, j.Id }).ToList();