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
5 answers

Which SQL Query is Better?

Is this SQL query statement: SELECT p.id, p.[name], SUM(ps.sales_amount) AS GROSS_SALES FROM products p LEFT OUTER JOIN product_sales ps ON p.id = ps.product_id GROUP BY p.id, p.[name] better than: SELECT SUM([t2].[value]) AS [SalesAmount],…
leypascua
  • 725
  • 1
  • 5
  • 13
5
votes
4 answers

c# convert predicate between each other

I'm developing and multi-tier application solution and my solution looks like this Business.DomainObject Business.Process (* Actual business layer) Data.Mapper Data.Repository Data.Sql.Entity (* Actual data layer that has .dbml file) My…
emregulcan
  • 88
  • 1
  • 5
5
votes
2 answers

Import Linq-To-SQL list to MongoDB

I have a very simple LinqToSql list. var list = DB.Where(c => c.Status.Equals("active")).Select(c => c.Name); I'm trying to import that list into MongoDB. Here's what I have so far: const string connectionString = "mongodb://localhost"; var client…
inquisitive_one
  • 1,465
  • 7
  • 32
  • 56
5
votes
5 answers

Linq to SQL: .FirstOrDefault() not applicable to select new { ... }

I just asked this question. Which lead me to a new question :) Up until this point, I have used the following pattern of selecting stuff with Linq to SQL, with the purpose of being able to handle 0 "rows" returned by the query: var person = (from p…
cllpse
  • 21,396
  • 37
  • 131
  • 170
5
votes
1 answer

Linq to Sql any keyword search query

I have a case in my application where the user can search for a list of terms. The search needs to make three passes in the following order: One for an exact match of what they entered. Done, easy. One where all the words (individually) match.…
Dusda
  • 3,347
  • 5
  • 37
  • 58
5
votes
5 answers

Linq to SQL & Logical partitioning (DAL, BLL)

We're going to be rebuilding one of our sites in .Net. I've read many articles and really like the idea of separating our project into a data access layer (DAL), Business logic layer (BLL), and presentation layer (we're coming from classic ASP so…
Chris Klepeis
  • 9,783
  • 16
  • 83
  • 149
5
votes
2 answers

What's the difference between these two LINQtoSQL statements?

These two statements look the same logically to me, but they're resulting in different SQL being generated: #1 var people = _DB.People.Where(p => p.Status == MyPersonEnum.STUDENT.ToString()); var ids = people.Select(p => p.Id); var cars =…
Kirschstein
  • 14,570
  • 14
  • 61
  • 79
5
votes
5 answers

Learn LinqToSql or stick with ADO.NET?

I'm debating what technology to use for an upcoming ASP.NET project. Assumptions: I will be using Visual Studio 2008 SP1 (.NET Framework 3.5) The back-end will be a SQL Server 2005 database (or possibly 2008) Code will be written in C# I already…
devuxer
  • 41,681
  • 47
  • 180
  • 292
5
votes
1 answer

MoreLinq maxBy vs LINQ max + where

I am using EF5 with the MoreLinq extenstion, while testing my program in production (very big database), I found out that the line: var x = db.TheBigTable.MaxBy(x => x.RecordTime); Takes very long time (RecordTime is a non-indexed datetime) Is that…
Ofiris
  • 6,047
  • 6
  • 35
  • 58
5
votes
2 answers

Aggregate Function in LINQ expression throws error. (cannot be translated into a store expression.)

Error: LINQ to Entities does not recognize the method 'System.String Aggregate[String,String](System.Collections.Generic.IEnumerable1[System.String], System.String, System.Func3[System.String,System.String,System.String])' method, and this method…
Scorpio
  • 1,151
  • 1
  • 19
  • 37
5
votes
1 answer

C# Razor Syntax - html.displayfor displaying as text, not html

My models: public class htmlDump { public string html { get; set; } } public string getSquares() { var sq = (from s in n.squares where s.active == true orderby s.date_created…
shubniggurath
  • 956
  • 1
  • 15
  • 31
5
votes
1 answer

Type inference failed in the call to 'Join' when using anonymous type

I have a peculiar problem with LINQ to SQL: Doing this is fine: from s in Something join a in AnotherThing on s.NullableDateTime.Value equals a.DateTime select s However, using anonymous type like so: from s in Something join a in AnotherThing on…
dav_i
  • 27,509
  • 17
  • 104
  • 136
5
votes
5 answers

LINQ To SQL in Compact Framework

Im on to design my Data Access for a new solution i create. That solution though contains Compact Framework Device Application and libraries besides Desktop. All .NET 3.5. Desktop will handle all Data Access basically. I need the Data Objects to…
George Taskos
  • 8,324
  • 18
  • 82
  • 147
5
votes
2 answers

Linq & unsupported data types (Geography)

So, Linq does not support the Geography data type, which throws a major spanner in the works in the lovely 'drag table onto the Linq design surface' developemnt model. Is there any way that I can extend Linq to work with the Geography datatype? Or…
Mr. Flibble
  • 26,564
  • 23
  • 69
  • 100
5
votes
1 answer

Really complex LINQ (to SQL) query example

We're thinking about adding more LINQ tests for ORMBattle.NET, but have no more ideas. All LINQ tests there are checking common LINQ functionality: Any test must pass on LINQ to IEnumerable For any test, there must be at least one ORM, on it passes…
Alex Yakunin
  • 6,330
  • 3
  • 33
  • 52