以下の SQL クエリを Linq に変換しようとしていますが、正確に動作させることができません。
select l.nid,
l.sName,
l.language,
coalesce(p.kLanguage, 0) kLanguage
from vLanguage l
left join
(
select pl.kLanguage,
p.nid,
p.sName
from vProductLanguage pl
left join vProduct p
on pl.kProduct = p.nid
where p.nid = 1
) p
on l.nid = p.kLanguage
where l.bClosed =0
私はここで私のWCFサービスでそう管理しました
[WebInvoke(Method = "PUT", RequestFormat = WebMessageFormat.Json, ResponseFormat = WebMessageFormat.Json, UriTemplate = "ProductLanguageList")]
public List<LookUpProductLanguage> GetProductLanguageList()
{
var passedProductId = int.Parse("12");
var query = from languageEntity in _languageEntityRepository.AsQueryable()
join subQueryResult in (from productLanguageEntity in _productLanguageEntityRepository.AsQueryable() join productEntity in _productRepository.AsQueryable() on productLanguageEntity.LanguageProductId equals productEntity.Id into joinedProductLanguage
from productLanguageJoin in joinedProductLanguage.DefaultIfEmpty() where productLanguageJoin.Id.Equals(passedProductId)
select new {LanguageId = productLanguageEntity.LanguageId}
) on languageEntity.Id equals subQueryResult.LanguageId
return null;
}
現時点では null を返しましたが、SQL クエリで言及されている列を返したいと考えています。line join subQueryResult の近くで「型引数をクエリから推測できません」というエラーが発生します。私はここで何をしているんだ?私は何か間違ったことをしていると確信しているので、私を修正してください。