For me, the second character is to crack the complex SQL set processing code to solve various domain model issues. However, the tendency is not to touch SQL anymore. Is there a link to a template or conversion tool out there that helps convert various SQL templates to Linq syntax?
I would look for ways to encode things like the following code: (this has a subquery):
SELECT * FROM orders X WHERE (SELECT COUNT(*) FROM orders Y WHERE Y.totalOrder > X.totalOrder) < 6
(Take the top five highest total orders with side effects)
Alternatively, as you know, Linq is executed as a single statement without using a debugger? I know you need to keep track of the listing, but I would suggest that you are just looking at the templates somewhere.
This is from the MSDN site, which is their example of making SQL difference. I am probably mistaken, but I would not think that it uses the given processing on the server (I think that it pulls both sets locally and then accepts the difference, which would be very inefficient). I am probably mistaken, and this may be one of the patterns in this link.
SQL difference example:
var differenceQuery = (from cust in db.Customers select cust.Country) .Except (from emp in db.Employees select emp.Country);
thanks
- Update:
- Microsoft 101 Linq Samples in C # is a closer linq builder in the SQL template you want. I will write more when I find them. I am really looking for a methodology (templates or conversion tool) for converting SQL to Linq.
- Update (sql from Microsoft difference template in Linq):
SELECT DISTINCT [t0].[field] AS [Field_Name] FROM [left_table] AS [t0] WHERE NOT (EXISTS( SELECT NULL AS [EMPTY] FROM [right_table] AS [t1] WHERE [t0].[field] = [t1].[field] ))
This is what we wanted, and not what I expected. So this is one pattern to remember.
c # sql linq
Zachary scott
source share