linq-to-sql

What are the advantages of EF4 or LINQ to SQL?

What are the advantages of EF4 and under what circumstances is it preferred over LINQ to SQL? ...

Null Values In Linq to sql

Hi.. I have table called Customers and this customer has Bank Details but Some customer they don't have, When i Use Linq to sql it's Return Null value, like a below example Table How to prevent this null into Default value 0 or String Ex. Table Customer ID Name bank name ----------- ------ -------------- J...

Challenges with Linq to sql concept in dot net

Hi, Let say if I used the Linq to Sql concept to interact with database from C# language , then what challenges I may be face? means in terms of architecture, performance , type safety, objects orientation etc ..! ...

How to convert Linq to SQL to Linq Entity?

hi I have the code below could you help me please to rewrite from LINq to SQL to Linq to Entity. thank you if(account.AccountID > 0) { dc.Accounts.Attach(account, true); } else { dc.Accounts.InsertOnSubmit(account); } dc.SubmitChanges(); ...

ExecuteQuery<> with hierarchy objects and LINQ to SQL

Let's say I have two objects: public class Person{ string Name { get; set;} Address Home { get; set;} } public class Address{ string Street{ get; set;} string City { get; set;} } string sql = "Select Name, Home_street, Home_city from user"; var results = dc.ExecuteQuery<Person>(sql); The problem here is ...

Is it possible to automatically prefix all table names in SQL Server and in LINQ to SQL?

I'm working on a few ASP.NET MVC projects which all require database functionality. Unfortunately, my hosting provider only gives me two SQL Server databases to work with, so I want to put the tables of multiple projects into a single database. However, some of my tables are similarly named, so I might run into some issues. Thus, I'm tr...

Throw Exception if record is a foreign key in another table

UPDATE: Probably should model my database to my objects correctly first! Found this tutorial http://www.codeproject.com/KB/linq/linqtutorial.aspx so should probably ignore this question! Hi All, Apologies if this already has a thread but I cant seem to find the answer I am looking for. I have an object Communication Type: [Table(Name ...

Problem with generating association inside dbml file for LINQ to SQL.

I have created a dbml file in my project, and then dragged two tables from a database into the designer. This is the tables for order header and order lines, and order lines have a foreign key to order header to make it a one to many relationship. As soon as the two tables are dragged onto the designer, the association arrow appear and ...

.Net LINQ to SQL Exception

I'm using C# , .NET and SQL Server with Linq2SQL. What does this error mean? Is it a insert or read/select related error? The function Classes.BLL.Save(LPage l) first selects COUNT from database and then INSERT a new record to database. 2010-09-03 04:57:56,264 System.Data.SqlClient.SqlException (0x80131904): Timeout expired. The tim...

Linq to SQL query, need to filter based on child/associated table?

I have a series of dropdown lists that contain all possible options held on my project table. Each time a dropdown is changed, I kick off a "refilter" that then updates all the other dropdowns so that the options in the boxes always reflect the results matching all the dropdowns - it's a dynamic filter basically. Now the project table ...

Is a join appropriate for accomplishing such functionality in LINQ to SQL?

I'm writing an ASP.NET MVC site where I'm using LINQ to SQL to access my SQL Server database. In my database, I have the following tables: Posts: PostID - int, PK, identity Text - nvarchar(MAX) PublishDate - datetime etc. PostTags: PostTagID - int, PK, identity PostID - FK to PK to Posts table TagID - FK to PK to Tags table Tags...

Using LINQ to count value frequency

I have a table ID|VALUE VALUE an integer field with possible values 0 - 4. How can I query the count of each value? Ideally the result should be an array with 6 elements, one for the count of each value and the last one is the total number of rows. ...

LINQPad still cannot find extension method 'Where' after adding System.Data.DataSetExtensions.dll

Hi there, I have to join results from 2 sprocs in LINQ but got the error message: 'System.Data.DataSet' does not contain a definition for 'Where' and no extension method 'Where' accepting a first argument of type 'System.Data.DataSet' could be found (press F4 to add a using directive or assembly reference) However after added the DataS...

Optimize code: Linq and foreach loop 15k records

this is my code void fixInstellingenTabel(object source, ElapsedEventArgs e) { NASDataContext _db = new NASDataContext(); List<Instellingen> newOnes = new List<Instellingen>(); List<InstellingGegeven> li = _db.InstellingGegevens.ToList(); foreach (InstellingGegeven i in li) { if (_db.Instellingens.Count(q => q....

WCF invalidoperationexception

Hi to all. I encounter this strange problem while using wcf services along with L2SQL DAL. The server is hosted at the localhost and contains an implementation of the correspondent interface. The client is familiar with the interface and occasionally queries the database via the exposed service using tcp transport. When client runs loca...

SubSonic 3, Entity Data Model (Entity Framework) or LINQ to SQL for ASP.NET MVC development?

Having used all of them (some more than others), I am still undecided on which could be the best to use (with .NET 3.5). What are the pro's and con's of each when developing? SubSonic 3 Not enough samples/documentation (I know its a wiki and people can update it, but it can be tricky to track things down - e.g. where are the sample apps...

Linq to Sql object not populated

I am new to Linq and am struggling with what I think is a deferred execution problem. I have a data layer in my application which uses Linq to Sql and then passes the entity through to the viewmodel using a WCF service (MVVM architecture). The object gets serialised at this point. I am passing thorough an Employee object which shoul...

Null values In Return Results

Hi, There, here's My Code: Dim QSD = From VM In cntxtVessel.VesselMasters _ Group Join cnt In cntxtVessel.CountryMasters On VM.CountryCode Equals cnt.CountryCode Into Cntry = Group _ From CM In Cntry.DefaultIfEmpty _ Group Join D In cntxtVessel.DestinationMasters On VM.DestinationCo...

Nullable object Value

Hi,.. "Nullable object must have a value." I got this error when execute n get the result (the linq to sql command) Dim QSs = (From VM In cntxtVessel.VesselMasters _ Group Join cnt In cntxtVessel.CountryMasters On VM.CountryCode Equals cnt.CountryCode Into Cntry = Group _ From CM In Cntry.De...

Linq to Sql Tutorials

Hi There, I am newbe to linq to sql using with vb.net please tell me where i can get the good articles, tutorials and vdo's thanks ...