linq-to-sql

Integrating Linq in a Classic ASP Site

This project is the probable first step in migrating a large CMS from Classic ASP to .Net. I'd like to use LINQ for querying the DB. Does anyone have any ideas for strategies to make this happen? I understand this is a vague question at this point, but I'm gathering information. Thanks, KevDog ...

Stored Procedure slower than LINQ query?

I was doing some testing and straight LINQ-to-SQL queries run at least 80% faster than if calling stored procedures via the LINQ query in SQL profiler a generic LINQ query var results = from m in _dataContext.Members select m; took only 19 miliseconds as apposed to a stored procedure var results = from m in _dataContext.GetMembe...

SQL 2 LINQ query (called by databinding) completely freezing WPF application

Earlier today I was hunting down a very weird bug... I finally traced it down to what seems to be causing the problem. The original report can be found here: original question The details have changed enough to warrant a new question. It would seem my application sometimes, NOT ALL OF THE TIME, freezes when it reaches the following LI...

Entity Framework & LINQ To SQL - Conflict of interest?

I've been reading on the blogosphere for the past week that Linq to SQL is dead [and long live EF and Linq to Entities]. But when I read the overview on MSDN, it appeared to me Linq to Entities generates eSQL just the way Linq to SQL generates SQL queries. Now, since the underlying implementation (and since SQL Server is not yet an ODB...

How can I change the UpdateCheck Attribute of a LINQ 2 SQL Column at runtime ?

We have a few applications that use the same Linq 2 SQL DataContext. One of those Apps wil do massive inserts (it's a convertor from an old system). Is it possible to change the UpdateCheck of the TimeStamp column of each table at runtime ? Only for this one app we'd like to set it to Never, all the other apps should have Always. ...

How would I serialize a LINQ-to-SQL lazy list

I have a linq query and I am trying to put that in to a serializable object for a distributed caching (Velocity) but its failing due to a LINQ-to-SQL lazy list like so return from b in _datacontext.MemberBlogs let cats = GetBlogCategories(b.MemberBlogID) select new MemberBlogs ...

How is the .net Entity Framework overkill versus LinqToSql?

I've heard it said that the Entity Framework is overkill or that it's difficult to learn compared to LinqToSql. I am wondering in what way? I used LinqToSql and like it. So, I am trying the EF and for the things I'm doing they seem almost exactly the same. Namespaces and method names are different but so far I don't see anything that...

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 SELECT o.OrderNumber, v.VendorName, s.StatusName FROM Orders o LEFT OUTER JOIN Vendors v ON v.Id = o.VendorId LEFT OUTER JOI...

Can I check wheter Linq 2 SQL's DataContext is tracking entities?

We want to throw an exception, if a user calls DataContext.SubmitChanges() and the DataContext is not tracking anything. That is... it is OK to call SubmitChanges if there are no inserts, updates or deletes. But we want to ensure that the developer didn't forget to attach the entity to the DataContext. Even better... is it possible to ...

.net SqlConnection not being closed even when within a using { }

Please help! Background info I have a WPF application which accesses a SQL Server 2005 database. The database is running locally on the machine the application is running on. Everywhere I use the Linq DataContext I use a using { } statement, and pass in a result of a function which returns a SqlConnection object which has been opened ...

LinqToSql Producing Different Sql Queries on Different Machines for Identical Code

I have a website built using Asp.net and LinqToSql for Data Access. In a certain section of the site, LinqToSql produces a query that looks like this (from my dev machine): select ... from table1 left outer join table2 on table1 where ... left outer join table3 on table2 where ... Since the connection between table2 and table1 is not ...

a ListView, a LinqDataSource, linq-to-sql and ordering

So I'm writing a page which does some reporting and it's pretty dynamic, the user has the ability to group data and sort columns. I've been able to get my dynamic grouping down and then the sorting except now my generated linq-to-sql sql order by statement is backwards from what I want it to be. I think I need to figure out how to get at...

LinqDataSource/ListView for child records - only save when the containing record is saved?

I have a single form for editing an event, in which the user can (a) edit the details of the event (title, description, dates, etc.) in a FormView and (b) view and edit a ListView of contacts who are registered for the event. Here's my LinqDataSource, which allows me to add and remove contacts to the event. <asp:linqdatasource runat...

LINQ to SQL disconnected updating object from different data context

http://geekswithblogs.net/michelotti/archive/2007/12/17/117791.aspx I'm using ASP.NET with C# and trying to use linq to sql to update a data context as exhibited on the blog linked above. I created the timestamp field in the table just as stated and am using the following method: private void updateRecord(TableName updatedRecord) { c...

Linq to SQL and large DB model

First, I am Linq to Sql newbie, so please be gentle :). I have existing ASP.Net application developed over last 3.5 years. It has pretty big data model underneath, around 350 tables. I am trying to do some new things with Linq to SQL. First impression is that linq designer and SqlMetal are built for databases not bigger than NorthWind...

Auto-increment a primary key in the LINQ to SQL DataContext "Insert" partial method

What I would like to do is the following. I have a single table, Products, containing a private key ProductID. Instead of having SQL Server auto-increment ProductID on inserts, I want to increment it in the DataContext partial method "InsertProduct": Partial Public Class MyDataContext Private Sub InsertProduct(ByVal instance As Pro...

nested linq queries, how to get distinct values?

table data of 2 columns "category" and "subcategory" i want to get a collection of "category", [subcategories] using code below i get duplicates. Puting .Distinct() after outer "from" does not help much. What do i miss? var rootcategories = (from p in sr.products orderby p.category ...

Do you think it's advantageous to switch to Entity Framework?

With LINQ to SQL most likely going to not get as much active development as Entity Framework do you think it's best to switch to Entity Framework? I've personally found EF to be very clunky and hard to use compared to LINQ to SQL which feels very natural. EDIT: I recently posted an article on my blog about my feelings towards this pote...

Get object's DataContext

If I have the LINQ objects: public class SampleDataContext : DataContext { public Table<Customer> Customers { get { return this.GetTable<Customer>(); } } public SampleDataContext( string connectionString ) : base( connectionString ) { } } [Table( Name="dbo.tblCustomers" )] public class Customer { private Guid? customerID; ...

Can I specify a set of base parameters for a Linq-to-sql DataContext?

I have a LINQ-to-SQL DataContext that represents a parent-child relationship of Products to Prices. I'm iterating through a list of products and retrieving the prices for each one. The problem is that the tables behind both the Products and Prices contain a list of Products or Prices for multiple environments, determined by a 3 field co...