select case statement in linq query.
Here is the query on sql:
- select case when DATEDIFF(day,convert(varchar,Min([Order].CreatedOnUtc),101),convert(varchar,Max([Order].CreatedOnUtc),101)) = 0 then
- Sum([Order].OrderSubtotal)
- else
- case when (DATEDIFF(day,convert(varchar,Min([Order].CreatedOnUtc),101),convert(varchar,Max([Order].CreatedOnUtc),101))/30) = 0 then Sum([Order].OrderSubtotal) else
- Sum([Order].OrderSubtotal)/
- (DATEDIFF(day,convert(varchar,Min([Order].CreatedOnUtc),101),convert(varchar,Max([Order].CreatedOnUtc),101))/30)
- end
- end as 'Account Value' from [order] where And Account.ID = @Act_ID
I am trying the code here:
- var query = _orderRepository.Table;
- query = query.Where(o => o.AccountId == accountId);
In query i am getting my value.
After query statement what should i write?? how do i write for case statement using linq???
2 Replies
Know the answer? Post it — somebody with the same question will find it here.
Sign in to answer this question
It is the same account you read, post and publish with — and you will come straight back to this page.
Nilesh ShahPosted Mar 4, 2017, 4:34 PM
Nilesh ShahPosted Mar 4, 2017, 4:33 PM