Questions tagged [linq-to-sql]

This tag is NOT ABOUT LINQ TO SQL TRANSLATION! Linq to SQL is an old ORM that's part of .Net framework, not core. For questions about LINQ to SQL translation please use the tag of the ORM in question.

LINQ to SQL

LINQ to SQL is a component of .NET Framework version 3.5 that provides a run-time infrastructure for managing relational data as objects stored in Microsoft SQL Server. The tag linq-to-entities should be used for questions about Entity Framework LINQ queries.

LINQ to SQL maps the data model of a relational database to an object model expressed in the programming language of the developer. When the application runs, LINQ to SQL translates the language-integrated queries in the object model into SQL and sends them to the database for execution. When the database returns the results, LINQ to SQL translates them back to objects that you can work with in your own programming language.

As of 2008, LINQ to SQL is no longer being actively developed, and Microsoft recommends using Entity Framework instead.

Introduction

Using LINQ to SQL

More information

14803 questions
5
votes
2 answers

Does changing isolation level using TransactionScope in LINQ to SQL for NOLOCK impact the connection?

I'm testing out using TransactionScope with options to set the isolation level to ReadUncommitted to execute specific queries with as such. What I'm seeing, however, is that because the isolation level is set on the connection, when the connection…
5
votes
1 answer

Warning says Linq-To-Sql Expression is always false, but this is incorrect, why?

I am getting a warning on the line noted in the comment in the code below. I am using Visual Studio 2015. I have 2 tables in a database, and querying them using Linq-2-Sql. The Linq Code performs a left join between the two tables on the companyID.…
Matthew Eskolin
  • 558
  • 1
  • 5
  • 20
5
votes
3 answers

In Memory Data Cache for Performance in .Net Applications

We have an application (rules engine) that has a lot of tables in memory to perform certain business rules. This engine is also used for writing back to the database when needed. The DB structure is denormalized, and we have 5 transactional tables,…
Faisal M
  • 173
  • 2
  • 6
5
votes
13 answers

Search query using .Contains() for parameters that combine two columns

I've got a table with FirstName and LastName and a query that looks somewhat like this: var TheQuery = (from c in MyDC.Contacts where (c.FirstName.Contains(TheSearchParameter) || …
frenchie
  • 51,731
  • 109
  • 304
  • 510
5
votes
1 answer

Filter a list of objects by comparing with another list of different objects

I have the following 3 classes in my dbml file: public class Player { public int PlayerID {get; set;} public string Name {get; set;} } public class PlayerItem { public int PlayerItemID {get; set;} public int PlayerID {get; set;} …
user330375
5
votes
0 answers

Is there a maximum number of entities or associations in LINQ-to-SQL?

I have problems with drag and dropping tables in the LINQ-to-SQL designer. And the associations (relations between the tables) are not configured automatically in the designer source. The file reached a number of 30.000 lines. Is there a maximum…
user1531040
  • 2,143
  • 6
  • 28
  • 48
5
votes
2 answers

Logic for displaying infinite category tree in nested

Please help me solve my big problem. in my on-line shopping project i created a dynamic Category List (with Infinite Level Depth) Implemented in a Single Table in DB with Self join. the schema is like below: (source: aspalliance.com) Update I want…
Mehdi
  • 5,435
  • 6
  • 37
  • 57
5
votes
2 answers

Entity Framework, LinqToSQL and sql injection

Is it possible for a project using entirely LinqToSQL or Entity Framewok to suffer from SQL Injection. I think that probably not because the SQL that the ORM generates should be sql-injection free. But I'm not sure.
Carlos Muñoz
  • 17,397
  • 7
  • 55
  • 80
5
votes
1 answer

Why should I use GetOriginalEntityState() in my LINQ To SQL repository save method?

I'm looking at an example of a save method in a Products repository from Steven Sanderson's book, Pro ASP.NET MVC 2 Framework: public void SaveProduct(Product product) { // if new product, attach to DataContext: if (product.ProductID == 0) …
quakkels
  • 11,676
  • 24
  • 92
  • 149
5
votes
4 answers

update .dbml file

How to update .dbml file after making some changes in the database.
Niraj Choubey
  • 3,942
  • 18
  • 58
  • 93
5
votes
1 answer

Why does LINQ-to-SQL sometimes allow me to project using a function, but sometimes it does not?

This is really puzzling me. I know LINQ-to-SQL handles selects by processing the expression tree and attempting to translate stuff via the generated query, which is why some function translations don't work property (string.IsNullOrWhitespace is a…
Anthony
  • 9,451
  • 9
  • 45
  • 72
5
votes
1 answer

Using a member access lambda expression to parametrise a LINQ to SQL predicate

I have a query that needs to be reused all over the place and I need to vary which property/column gets used for a join. What I'd like to be able to do is something like: query = RestrictByProp(query, x=>x.ID); An extremely simplified…
stucampbell
  • 6,383
  • 5
  • 26
  • 25
5
votes
1 answer

SQL 'comment' that can be read in a sql profiler

I've tried several methods such as using double hyphens, i.e. --THIS IS A COMMENT but when the executed sql is read in a profiler the comment is stripped out leaving only raw SQL that is being performed. I want to do this to enable rapid…
5
votes
0 answers

SQLite and LINQ to SQL - Problems with DataContext and database creation

I write a .NET application in C# which is using SQLite database. And I want to use LINQ to SQL as ORM in order to work with database. So two nuget packages are installed in my project for that reason: System.Data.SQLite Core (x86/x64) and…
Alex
  • 887
  • 1
  • 11
  • 29
5
votes
2 answers

Is it possible to return multiple result sets using ExecuteQuery in Linq to Sql?

I know that you can return multiple results from a stored procedure and through the method generated by the designer. However, I'm trying to do the same using ExecuteQuery but it doesn't seem like it's possible. Has anyone tried or know whether this…
Jiho Han
  • 1,610
  • 1
  • 19
  • 41