linq-to-sql

What are the major differences between Data Access Application Block, NHibernate, ADO.NET Entity Framework and LINQ to SQL?

What are the major differences between Data Access Application Block, NHibernate, ADO.NET Entity Framework and LINQ to SQL with respect to performance, business logic, scalability and flexibility? ...

NHibernate's out of the box features.

How does NHibernate provide out of the box features as compared to the other OR/M tools available like ADO.NET entity framework and LINQ to SQL? ...

database setup for Unit testing Linq to Sql, where database have relationships

I google around unit testing LINQ to SQL and people are using MockDatabase class where we have list and add data to those Lists. This will fit in the scenarios where we dont have relationships. I am behind using some data or mdf file in the unit test project which will have the same structure as like my actual database with all relation...

query results cannot be enumerated more than once error

Hello I have a problem where I call a stored proedure twice, each with different parameters and I need 2 seperate lists but linq is caching the data and also giving me the error above I have tried 2 different methods to get round the error message, one using ToList() on tbl and the other manually walking through the data My code is sh...

Entity classes created by Entity Framework and LINQ to SQL

HI , The designer creates Entity classes as partial when using LINQ to SQL and the Entity Framework. Is there some way we can create the Entity classes as .cs physical files while using LINQ to SQL or the Entity Framework ...

linq to sql - loop through table data and set value

I have a table "Users".. it has a column "ShowData" using linq-sql how can I loop through every user and set ShowData to false for each user.. thanks ...

Are static methods appropriate for a Linq To SQL DAL?

Hey, I'm using Linq to SQL for my DAL and have heard various things about using static methods in a web application (regarding threading/concurrency issues). At the moment, I created a test DAL, which seems to be functioning fine. However, are there any problems with the way I've created it, since it's static? public static class ...

How do i change order of properties in DBML file (L2S)

How do i change order of properties in DBML file (L2S) I really do not want delete and then re-drop my table from database ...

Convert DataTable to Linq

I'm trying to convert DataTable to Linq using DIm result = From r in dt.AsEnumerable() Select new ( col1 = r.Field<integer>("id"), col2 = r.Field<string>("desc")) But i get error near 'new (' saying type expected. What is wrong with this query? ...

Best way to store this data in SQL Table

I am trying to best figure out a way to store this particular case of data in a static database table on the front end the user will be presented with a simple table (say 5x5 by default) but the user can expand or delete rows/ columns at will. The idea is that the first column will be labels that are the same as the headers, similar to...

LINQ TO SQL Query

I have a LINQ TO SQL query which retrieves all the users along with their roles: var userRoles = from u in db.GetTable<User>() join ur in db.GetTable<UserRole>() on u.UserID equals ur.UserID join r in db.GetTable<Role>() ...

Linq to SQL equivalent of SUM GROUP BY SQL statement

Hi everybody! I'm having a hard time figuring out how to translate this simple SQL statement to (c#) linq to SQL : SELECT table1.vat, SUM(table1.QTY * table2.FLG01 + table1.QTY * table2.FLG04) FROM table1 inner join table2 on table2.key= table1.key where '2010-02-01' <= table1.trndate and table1.trndate <= '2010-02-28' Group by ta...

Reducing roundtrips between client and server

Hi, We are developing desktop application in vs2008 with winforms and sql server 2008.At present, we make lot of dbase calls(linq to sql) on form load, so this make the application real slow.One option is to load all the data required at the start of application load, and store it in a cache(just static collections).What other options w...

One-to-one association and filtering in Linq

Hello, Let's say I have two tables (Address and Phone) in sql which have one-to-one relationship. I have created corresponding linq to sql classes and changed the association to OneToOne I want to retrieve both objects by filtering child object. e.g I have the following query which works fine: var n = db.Addresses.Where(t => t.Phone.N...

Using a plain Entity class to map to a table using LINQ to SQL?

Suppose I have written a class Customer which has it attributes as Name, Age, designation etc. And I have a table also as customer with the same attributes. Now I dont want to use the designer provided that generates the entity classes for me. Is it possible for me to map the Customer.cs to the table customer while using LINQ to SQL as...

Convert this SQL to linq2SQL

Can someone convert this query to linq2sql for me? Trying to teach myself linq to see if I want to use it for a small project, and getting hung up on the smallest details... SELECT Warrant.ID, Warrant.MeetingDate, Warrant.MeetingType, Warrant.Notes, COUNT(WarrantArticles.ID) AS Cnt FROM Warrant INNER JOIN WarrantArticles...

linq to sql with multiple aggregators

Hello everybody! I want to translate this simple SQL statement to linq-to-sql: SELECT SUM(field1), SUM(field2) FROM TableName The closest linq-to-sql is (i think) using the group by clause: from tbl in TableName group tbl by (1) into g select new{ value1= g.Sum(p => p.field1), value2 = g.Sum(p => p.field2)}; As this does not produ...

Saving and Retrieving Entities of different types using LINQtoSQL

Disclaimer: Bit of a C# newbie - first Software Dev gig in awhile after being in QA for a couple years. I realize flavors of this question have been asked before (inheritance in LINQtoSQL and the like), but I'm hoping I ask the question differently. In my database, I will have a super-type of "Event" and multiple sub-types: Conferenc...

Facing strange linq to sql problem

Hi, I have a table called currency.Now, the id of this table is a fk in many tables.Now,when I load currency(using linq to sql currency.tolist()), the data of one association is loaded.I don't understand why is it so.I don't want to load data of any association.How can I do this? ...

LINQ To SQL: Filtering a query across many tables

I've inherited this project from the previous guy, and I'm presently in the process of switching over a number of assembled-from-string SQL queries into LINQ to SQL, which I'm told is what makes life in .NET worth living. However, I'm running into problems filtering a Many-to-Many relationship. The system is a Project Management intr...