Plateforme Level Extreme
Abonnement
Profil corporatif
Produits & Services
Support
Légal
English
T-SQL query to LINQ
Message
 
 
À
20/10/2014 13:44:52
John Baird
Coatesville, Pennsylvanie, États-Unis
Information générale
Forum:
ASP.NET
Catégorie:
LINQ
Versions des environnements
Environment:
C# 4.0
OS:
Windows 7
Network:
Windows 2003 Server
Database:
MS SQL Server
Application:
Web
Divers
Thread ID:
01609660
Message ID:
01609667
Vues:
36
>>>>>Off the top of my head, if I understood your problem correctly. It would be something like this:
>>>>>
>>>>>var list = (from  d in _dbSet.Where(x => x.Account == accountName && x.Hidden == false)
>>>>>               from t in transact .Sum(s=>s.extension).Where(w=>w.extension != null && w.invoiceNo == d.InvoiceNo).
>>>>>              select(x => new InvoicesList { InvoiceNo = x.InvoiceNo, Account = x.Account, Hidden = x.Hidden, 
>>>>>                                                          Descrip = x.Descrip1, Finalized = x.Finalized, Created = .DateTime}, InvoiceBalance= t)).ToList();
>>>>>
>>>>
>>>>I am trying to use this syntax, but getting errors and can not figure this out. Here is my attempt, but I don't see where to put Sum here:
>>>>
>>>>
>>>> var invoicesList =  (from  d in _dbSet.Where(x => x.Account == accountName && x.Hidden == false)
>>>>                 from i in _siriusContext.Transact.Where(w=>w.Extension != null && w.InvoiceNo == d.InvoiceNo)
>>>>                select(x => new InvoicesList { InvoiceNo = x.InvoiceNo, Account = x.Account, Hidden = x.Hidden, Descrip = x.Descrip1, Finalized = x.Finalized, Created = x.DateTime, Balance= i.Extension}))
>>>>
>>>
>>>My example had the sum in it... btw, what are the errors?
>>
>>If I leave sum where you have it, then it says that decimal doesn't have Sum operator (something along the lines).
>>
>>I found this sample http://stackoverflow.com/questions/1285710/linq-to-sql-join-and-sum which I'll try to adapt now.
>
>You're amazing... rather than figure out the code and the problem, you flit off to another solution to try (read someone elses code). Why don't you keep at the linq statement until you solve the problem on your own and learn from it.
>
>There's nothing preventing summing on decimals...

I was wrong in telling you the problem. The problem with your code is that there is no Where operator on decimal.

Since I can not figure your syntax, I am trying to find other samples. Unfortunately, I can not so far make that one I found work either.

I am reading more into the syntax and looking into various samples trying to adapt to my case.
If it's not broken, fix it until it is.


My Blog
Précédent
Suivant
Répondre
Fil
Voir

Click here to load this message in the networking platform