linq-to-sql

Viemodel with stored Procedure

I am following the tutorial of scott gu from Here to retrieve the data using stored procedure. i am setting the return type of the stored procedure by dropping the SProc on class. Now my question is that can we set some viewmodel as the return type of the stored procedure, as my view is strongly typed with my viewmodel ...

Where can I find a (preferably free) good Linq2Sql designer guide?

I've looked for books, but couldn't find any, looked for it on the web, but nothing seems comprehensive enough. Where can I learn it? Thanks. ...

LINQtoSQL , repository pattern and lazy load

How do you use LINQtoSQL with the repository pattern? I’m new to L2S and find its lazy loading to be a real impediment to using the repo pattern. Usually, I think of the repository pattern like this: var myCustomer = null; using (var myRepo = new Repo()){ myCustomer = myRepo.GetCustomerForCustomerId(123); } if(myCustomer.Or...

When does the defered execution occur?

I've got a situation which I want to fetch data from a database, and assign it to the tooltips of each row in a ListView control in WPF. (I'm using C# 4.0.) Since I've not done this sort of thing before, I've started a smaller, simpler app to get the ideas down before I attempt to use them in my main WPF app. One of my concerns is the...

Linq to SQL Weird Error

I am getting this error: Could not format node 'Column' for execution as SQL When I am trying to make any anonymous type: select new { NounTypeName = nt.Name, Attributes = ( from a in nt.NounTypeAttributes group a by a.Attribute into g select new { NounTypeId = nt.NounTypeId, ...

LINQ to SQL use of => operand on String not allowed

Possible Duplicate: string1 >= string2 not implemented in Linq to SQL, any workarround? To give a brief summary of what I want to achieve we have a table called Application and it stores application version numbers. The contents of that Table for example is ApplicationID VersionID 1 R1.01.01.01 ...

exposing sql server data from an asp.net webapp to silverlight and win forms via linq

hi, I have an asp.net web app which holds its data in an sql server 08 r2 db. I have a silverlight admin interface on the same web app, and I will have a win forms app which will need to add/retrieve data from the sql db. Is there a way I can use linq in both clients? I mean something like linq2twitter, where in the silverlight or in ...

Linq to SQL Performance

Succinct How do I performance tune my Linq To SQL DAL methods? Specifically the amount of data being transferred. Verbose I have a Winform app that uses Linq To Sql to access it's data. We have 5 branches, 1 physically at the same location as the SQL server and the other 4 at various distances and bandwidths. My app is your typical...

SQL server Timeout – only happens very occasionally

Hello, I have a web application that occasionally will throw this error…. Exception message: Timeout expired. The timeout period elapsed prior to completion of the operation or the server is not responding. When I does I am unable to connect to SQL server, even through management studio, it’s says the server timed out and c...

Working with Linq2Sql with multiple joins and various sorts

Hello all, I have another Linq2Sql question I'm hoping I can get help with. In addition to working through to an answer, I'd love to get some "insight" to your thought process. Linq2Sql is still far from natural for me to work with, some of it has to do with the many ways in which it's syntax can be generated. OK, what I'm trying to s...

Linq to SQL Contains Method Throwing Unsupported Overload Exception

I have a List and each Filter object has a property called "Id". I want to fetch all the records from my database using Linq to SQL that contains those ids. The List is not part of the database it is just an independent list. ...

Linq to SQL Data Concurrency - Is it safe to use only PKs?

I am getting an error in my MVC-based website surrounding data concurrency in Linq to SQL: "Row Not Found Or Changed" After reading several posts on here it seems as though an accepted solution is to set all non-Primary key fields to UpdateCheck = false in the dbml designer. Before taking the plunge with this, I wanted to ask, will I ...

Linq conditional query in C#

I have the following two database tables. A group contains multiple members. Groups: Id (int) | Name (int) Members: Id (int) | GroupId (int) | IsExpert (bit) I need to write a linq to sql query that returns the Groups that has no experts. Need some help ...

Convert SQL query to LINQ to SQL

How do you convert a SQL query with nested SELECT statements to a LINQ statement? I have the following SQL statement which outputs the results I need but I'm not sure how to replicate this in LINQ . SELECT X.ITMGEDSC, (SUM(X.[ENDQTY_I]) - SUM(X.[ORDERLINES])) AS AVAIL FROM SELECT T1.[MANUFACTUREORDER_I],T2.[ITMGEDSC],T1.[ENDQTY_I], (S...

A very interesting problem with SQL Server Relationships (SQL Server 2008R2, LINQ To SQL, Visual Studio 2010, C#)

I'm working on a web project. I'm using a Sql Server 20008 R2 database via LINQ To SQL, and today I faced a very strange problem with relationships. I've been using them for a while and never had any problems so far. Let's say I have a table Stores that has the following fields: ID, Name, LastUserID where LastUserID is a "reference" to ...

Bad Storage property exception when trying to implement linq-sql in a WCF service

I've been trying to get a WCF service to access a file database that is stored on a local file system to no avail currently. I created a database called data.mdf in visual studio 2010 and ran this sql query on it. create table Person (PersonID int identity (1000,1) not null, Name nvarchar(50) not null, Address nvarchar(max...

Linq to SQL: Get number of consecutive daily views

I have a table that records when a user views a page. The table looks something like this: ID | Date 1 | 01/01/10 00:00:01.000 2 | 03/01/10 00:00:01.000 3 | 03/01/10 00:00:02.000 4 | 04/01/10 00:00:01.000 5 | 05/01/10 00:00:01.000 6 | 05/01/10 00:00:02.000 7 | 05/01/10 00:00:03.000 Using Linq-to-SQL I want to count the last gro...

Silverlight Webservice Problem

Hello, I have a webservice that calls a method and returns a generic list. The webservice completed method looks like this (note: names and e.Result are both of the same type of List): void SetNames() { ServiceReference1.ServiceClient webservice = new ServiceReference1.ServiceClient(); webservice.GetNameCompl...

How to convert a query consisting of INNER JOIN, LEFT JOIN and GROUP BY to a similar linq2sql query?

I'm trying to convert the following T-SQL query to linq2sql one. Whatever I do, it translates it to some nasty stuff with cross joins. Any suggestion? Given tables A, B, C SELECT A.Id, A.Name, Pool.Total FROM A INNER JOIN B ON A.Id = B.AId LEFT JOIN ( SELECT AId, SUM(Quantity) as Total FROM C GROUP BY AId) AS Pool ON A.Id = C.AId WHER...

LINQ orderby FK using a left join

Hi, I have the following code: from _categories in context.SCT_Categories join _categoryOrders in context.SCT_CategoryOrders on _categories.ID equals _categoryOrders.CategoryID into joinedData from _categoryOrders in joinedData.DefaultIfEmpty() orderby _categoryOrders.OrderIndex descending select _categories Which does a left join on...