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

TransactionScope Error against Sql Server 2000 - The partner transaction manager has disabled its support for remote/network transactions

I am trying to set up a simple transaction for my Linq-to-Sql actions against my Sql 2000 database. Using TransactionScope it looks like this: using (TransactionScope transaction = new TransactionScope()) { try { …
Bramha Ghosh
  • 6,504
  • 4
  • 30
  • 29
5
votes
4 answers

Can't access related data after disposal of DataContext in Linq to SQL

Restated my Question, old Text Below As I am still hoping for an answer I would like to restate my question. Image I have a GUI with two lists, one that shows a List of all entries to a database tblOrders and another one that shows the items in each…
Jonidas
  • 187
  • 4
  • 21
5
votes
1 answer

Can I safely intermix Linq-to-SQL queries and non-Linq-to-SQL queries on the same DataContext.Connection?

Suppose I have code in this form: using (var dc = new MyDataContext()) { // ...code that may or may not look up objects via Linq-to-SQL... // ...code that may or may not *update* objects via Linq-to-SQL... // and call SubmitChanges... …
T.J. Crowder
  • 1,031,962
  • 187
  • 1,923
  • 1,875
5
votes
4 answers

LINQ to SQL Basic question - table relationships

I'm playing with an image gallery in ASP.NET MVC, and trying to get my head around LINQ to SQL at the same time. I have 3 tables to hold image gallery data, with a many-many relationship through a link table. These are : Gallery (Id, Name,…
ZombieSheep
  • 29,603
  • 12
  • 67
  • 114
5
votes
2 answers

How to generate SQL COUNT(*) OVER (PARTITION BY {ColumnName}) in LINQ-to-SQL?

Is it possible to generate the following SQL query by using LINQ-to-SQL query expression or method chains which is defer-executable? Data Structure alt text http://www.freeimagehosting.net/uploads/e062a48837.jpg Select Distinct ClassRoomTitle, …
Thurein
  • 2,536
  • 7
  • 34
  • 49
5
votes
3 answers

Creating Database Mocks in ASP.NET MVC using Data from Existing Database

I have an existing ASP.NET MVC application with some sample data in the SQL Server database, which is working fine.. Assuming I have all of the necessary repositories and IOC in place, is there a tool that will extract the data from a group of…
Robert Harvey
  • 178,213
  • 47
  • 333
  • 501
5
votes
3 answers

want a Query to make order by variable in Linq query

How to make order by Column variable because I have a dropdown on page and I want to show grid according to sord order selected in this Dropdown e.g Price, Code, rating, description etc etc. and I donot want to write a separate query for each…
Azhar
  • 20,500
  • 38
  • 146
  • 211
5
votes
2 answers

Accessing properties through Generic type parameter

I'm trying to create a generic repository for my models. Currently i've 3 different models which have no relationship between them. (Contacts, Notes, Reminders). class Repository where T:class { public IQueryable SearchExact(string…
Amsakanna
  • 12,254
  • 8
  • 46
  • 58
5
votes
3 answers

Linq to SQL update not working using Repository pattern

I am using asp.net mvc for an application. I've taken some guidance from Rob Conery's series on the MVC storefront. I am using a very similar data access pattern to the one that he used in the storefront. However, I have added a small difference…
dp.
  • 8,138
  • 7
  • 33
  • 28
5
votes
1 answer

Linq PredicateBuilder with conditional AND, OR and NOT filters

We have a project using LINQ to SQL, for which I need to rewrite a couple of search pages to allow the client to select whether they wish to perform an and or an or search. I though about redoing the LINQ queries using PredicateBuilder and have got…
richeym
  • 4,049
  • 3
  • 24
  • 23
5
votes
4 answers

Is it possible to create custom methods in entity classes in linq to sql

I have a table Site in SQL with (amongst others) three properties idReviewer1, idReviewer2, idReviewer3. Now I would like to create a methods on the entity class of Site to check if a user is a reviewer: partial class Site { public bool…
doekman
  • 18,750
  • 20
  • 65
  • 86
5
votes
0 answers

MSDTC attempts to enlist client machine in a distributed transaction

We're seeing the following intermittent warning logged by MSDTC: A caller has attempted to propagate a transaction to a remote system, but MSDTC network DTC access is currently disabled on machine 'X'. Please review the MS DTC configuration…
5
votes
3 answers

Linq to SQL and Entity Framework differences?

What is the differences between those 2 assuming I'm using SQL Server as my database? Are they the same?
Funky81
  • 1,679
  • 4
  • 18
  • 24
5
votes
2 answers

LINQ To SQL Dynamic Select

Can someone show me how to indicate which columns I would like returned at run-time from a LINQ To SQL statement? I am allowing the user to select items in a checkboxlist representing the columns they would like displayed in a gridview that is bound…
mcass20
  • 1,668
  • 1
  • 22
  • 39
5
votes
1 answer

C# XML documentation of Linq to SQL

How to document the classes & properties & functions that are generated automatically using LINQ to SQL DBML? I managed to provide documentation to the datacontext class by defining the same partial class in another file with so it won't…
Katia
  • 679
  • 2
  • 15
  • 42