【发布时间】:2011-01-09 18:29:53
【问题描述】:
我们有两个相关的表(inventory、inventoryLocalization)和一个 t-sql 查询对它们进行如下处理..
select inv.[code],
coalesce(inL.name, inL2.name) as [name],
coalesce(inL.description, inL2.description) as [description]
from dbo.[inventory] inv
left join dbo.[inventoryLocalization] inL on inv.code = inL.code and inL.language = 'de'
left join dbo.[inventoryLocalization] inL2 on inv.code = inL2.code and inL2.language = 'en'
where inv.[code] like '15.' + '%'
order by inv.[code];
为了提高性能,我们将尝试使用缓存中的这些表,而不是直接从 RDBMS 中使用。 对于 asp.net 4.0 项目,由 c# 编写。 我们已经使用 DataSet 将两个表都用于 chache,并且我们可以通过该 DataSet 访问它们。
DataSet ds = UtilityCache.getCachedDataSet();
“ds.Tables[0]”是inventory表,“ds.Tables[1]”是inventoryLocalization表
但是我们如何将上面的 T-Sql 语法转换为 linq2Sql。 是否可以对 select 语句使用 coalesce 并在具有多个条件的两个表上连接?
提前谢谢..
【问题讨论】:
标签: c# asp.net linq linq-to-sql c#-4.0