C# – Linq to Sql – Reattach and Update an entity

If you’d listen to Microsoft, you’d believe than in Linq to SQL, you can’t reattach a changed entity to a new DataContext and submit the changed entity to the database. Well this isn’t true. It can be done with a little bit of foresight. The first step is to make sure that the underlying table … Read moreC# – Linq to Sql – Reattach and Update an entity

C#: Use verbatim strings for SQL queries

Using verbatim strings for SQL queries can make your code much more readable. For example, which one of the following queries is easier to read? This one? string query = @” SELECT User.FirstName, User.LastName, User.Age, User.Gender, User.HairColor, Adress.Street, Adresse.Zip, Adress.City, Adress.Country FROM User INNER JOIN Adress ON User.AdressId = Adress.Id SORT BY User.FirstName, User.LastName “; … Read moreC#: Use verbatim strings for SQL queries