简体   繁体   中英

need help in linq

I need help in linq

from refoffence in Ref_OffenceCodes join
offenceCodeMatrix in INF_OffenceCodeMatrixes on refoffence.OffenceCodeId equals offenceCodeMatrix.OffenceCodeId
where refoffence.Code=="1909"
select new {offenceCodeMatrix.StandardPenaltyUnits * offenceCodeMatrix.StandardDollarAmount }

I need muliplication of StandardPenaltyUnits and StandardDollarAmount as a result.

Please debug the query.

Well, one problem is that you're trying to create an anonymous type with a multiplication operation, but you're not specifying a name. Why are you using an anonymous type at all? You could try:

from offenceCode in Ref_OffenceCodes
join codeMatrix in INF_OffenceCodeMatrixes
on offenceCode.OffenceCodeId equals codeMatrix.OffenceCodeId
where offenceCode.Code=="1909"
select codeMatrix.StandardPenaltyUnits * offenceCode.StandardDollarAmount

However, it's hard to tell what's wrong as you only provided the failing code, without any indication of the way in which it's failing. The final line was a problem, but it may not have been the only one.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM