79
votes
5answers
57k views

Linq to Sql: Multiple left outer joins

I'm having some trouble figuring out how to use more than one left outer join using LINQ to SQL. I understand how to use one left outer join. I'm using VB.NET. Below is my SQL syntax. T-SQL ...
12
votes
2answers
497 views

Make Linq to Sql generate T-SQL with ISNULL instead of COALESCE

I have a linq to sql query that returns some orders with non zero balance (in fact, the query is a little bit complicated, but for simplicity I omitted some details). This query also should return ...
9
votes
4answers
9k views

Instead of trigger in SQL Server loses SCOPE_IDENTITY?

I have a table where I created an INSTEAD OF trigger to enforce some business rules. The issue is that when I insert data into this table, SCOPE_IDENTITY() returns a NULL value, rather than the ...
9
votes
3answers
5k views

Linq To SQL and Having

I am fairly new to Linq To SQL but trying to run what should be a fairly simple SQL query and can't figure out how to make it play nice in LINQ. SELECT Users.Id, Users.Id AS Expr1, ...
8
votes
5answers
8k views

Select case in LINQ

how can I translate this into LINQ? select t.age as AgeRange, count(*) as Users from ( select case when age between 0 and 9 then ' 0-25' when age between 10 and 14 then '26-40' when ...
6
votes
1answer
214 views

Bug in LINQ to SQL with empty strings on database

I have been using LINQ to SQL for years now, but this is the first time I have seen this behavior. I have a DB table with a few columns (varchar(15)) that may contain empty strings (''). I verify ...
6
votes
3answers
6k views

Checking for time range overlap, the watchman problem [SQL]

I am running into a road block on a larger problem. As part of a large query I need to solve a "night watchman" problem. I have a table with schedule shifts as such: ID | Start | End 1 | ...
5
votes
2answers
4k views

LINQ to SQL: Stored Procedure Results

How can I change the class name of stored procedure result generated by LINQ to SQL designer (besides messing with designer.cs)? Also, how can you perform a linq query on the result set of the stored ...
5
votes
1answer
2k views

LINQ Join On Between Clause

I am having some issues throwing together a LINQ query that will join a table based on a zip code. I need to join the table based on whether the customer's zip code lies with in a range of zip codes ...
4
votes
4answers
2k views

T-SQL IsNumeric() and Linq-to-SQL

I need to find the highest value from the database that satisfies a certain formatting convention. Specifically, I would like to find the highest value that looks like EU999999 ('9' being any ...
4
votes
1answer
141 views

Optimal Count() operation from a DB using LINQ to SQL

DBAs have told me that when using T-SQL: select count(id) from tableName is faster than select count(*) from tablenName if id is the primary key. Extrapolating that to LINQ-TO-SQL is the ...
4
votes
4answers
71 views

Need help creating a linq select

I need some help creating an LINQ select, i have a table with some columns in it, but only 2 of interest to this problem. userid, type Now this table have many thousands entries, and I only want ...
4
votes
3answers
173 views

What's the equivalent of “SELECT SYSTEM_USER” in Linq

I can get the identity of the currently logged in SQL Server user by using the SYSTEM_USER value, but is there a way to do this via linq somehow? I'm looking for something like the below: var query = ...
3
votes
3answers
441 views

Does LINQ to SQL support the t-sql “in” statement

I dont't know how to describe the title better (so feel free to change) but essntial I want to produce the equivilent of the following statement in LINQ to SQL: select * from products where category ...
3
votes
5answers
187 views

How to write this T-SQL in LINQ to sQL?

select * from table1 where pkey1 in (select pkey2 from table2 where column1='abc') Where pkey1 and pkey2 are both int columns.

1 2 3 4 5 7
15 30 50 per page