80
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 ...
68
votes
6answers
40k views

Case insensitive string compare in LINQ-to-SQL

I've read that it's unwise to use ToUpper and ToLower to perform case-insensitive string comparisons, but I see no alternative when it comes to LINQ-to-SQL. The ignoreCase and CompareOptions arguments ...
15
votes
3answers
636 views

The member 'X' was changed to be inconsistent with the association member 'Y'

I get this error if I follow these steps: Change property Y of an object (an associated entity property) Attempt to submit changes At this point the value of Y and the value of X (the underlying ...
13
votes
5answers
5k views

LinqToSql declare and instantiate DataContext best practice?

What's the best practice in terms of setting up my DataContext for easy access in my extended LinqToSql classes? For example, I have a "User" entity in my dbml and I want to add methods to that ...
12
votes
2answers
42k views

Sum and Group By in Linq to SQL?

Just getting started with Linq to SQL so forgive the newbie question. I'm trying to reproduce the following (working) query in Linq to SQL (VB.NET): Select f.Title, TotalArea = Sum(c.Area) ...
11
votes
2answers
310 views

Is Aggregate fatally flawed because each into clause is executed separately?

Is VB.NET's Aggregate query fatally flawed when used as the first (outer) clause of a Linq expression with multiple Into clauses because each Into clause is executed separately? The "obvious" answer ...
10
votes
2answers
13k views

How to order by multiple columns using VB.Net lambda expressions

I've done a brief search of this site, and googled this, but can't seem to find a good example. I'm still trying to get my head around the whole "Lambda Expressions" thing. Can anyone here give me an ...
7
votes
3answers
5k views

Setting Foreign keys in Linq to SQL

It's well known that you cannot set foreign key IDs directly in Linq to SQL if the entities have already been loaded. You can however look up the entity by it's foreign key and then set the entity as ...
6
votes
3answers
2k views

How to determine why a distributed transaction is timing out

I am using LINQ to SQL and a third party SDK that supports distributed transactions. When I realize that a pending update will be updating both SQL records and records in the third party SDK, I am ...
6
votes
3answers
3k views

Does Entity Framework/LINQ to SQL Data Binding use reflection?

Forgive me if this has been asked before; I did a search but couldn't find anything that specifically answered this question, but I'd be happy to be referred. I'm taking a peek at both the Entity ...
5
votes
5answers
5k views

How to get the primary key from a table without making a second trip?

How would I get the primary key ID number from a Table without making a second trip to the database in LINQ To SQL? Right now, I submit the data to a table, and make another trip to figure out what ...
5
votes
1answer
728 views

Sort blank entries to bottom of LINQ query

I am trying to sort a LINQ to SQL query based on two fields. The first field is occasionally null which automatically sorts to the top of an ascending query. Is there any way to make the null ...
5
votes
4answers
3k views

Unable to cast object of type 'System.Int32' to type 'System.String'

I'm getting a sporadic 'Unable to cast object of type 'System.Int32' to type 'System.String' Exceptions at .SingleorDefault() in the below code. It works 9/10 times but randomly it throws an ...
4
votes
3answers
14k views

InsertOnSubmit = Cannot add an entity with a key that is already in use

I am trying to insert a record into a table using Linq but get the dreaded Cannot add an entity with a key that is already in use error 'If the same data exists for the same patient in a record less ...
4
votes
1answer
2k views

ASP.NET - Advanced Where-Clause in LinqDataSource

I have two tables: Orders OrderProducts - An order can have 1 to many orderProducts records associated with it. What I am trying to do (unsuccessfully) is to implement a GridView search using a ...

1 2 3 4 5 24
15 30 50 per page