linq-to-sql

Which data framework is better for an ASP.NET MVC site - LINQ to SQL or NHibernate

We're about to embark on some ASP.NET MVC development and have been using our own entity framework for years. However we need to support more than our entity framework is capable of and so I'd like to get some opinions about using MVC with a more robust framework. We have narrowed down or choices to either NHibernate (with the Fluent API...

LINQ Object Persistance

Using the following code here Sub FooSub Dim db As New FooDataContext Dim u = From p In db.FooTable Where p.FooColumn = FooData Select p Do Stuff End Sub Do I have to manually create a class to map the data from my FooTable if I want it to persist in the application? If I declare u as a class-wide variable, then once SubFoo ends, I c...

When does Linq's Take, take the results?

Does it take the number specified and stop while querying or after the entire list is already in the collection? WHat performance benefit if any is there when uysing 'take'? ...

LINQ: Condition in table and in related table

I have some items called tickers which can be created and subscribed to. When they are created, they have a scope of 1:private or 2:public. Public tickers can be subscribed to by anyone and private tickers can be subscribed to by owner invitation. I want to use LINQ to get the tickers created by a user (ie: with a certain owner id) whic...

Apply properties values from one object to another of the same type automatically?

What I want to do is Given 2 objects A and B of type T, apply the properties values in A to the same propertie in B without doing an explicit assignment for each property. I want to save code like this: b.Nombre = a.Nombre; b.Descripcion = a.Descripcion; b.Imagen = a.Imagen; b.Activo = a.Activo; doing something like a.ApplyPropert...

Linq to SQL Strange Caching?

Hi all, I've got a strange (correct me if I'm wrong) bug/feature with Linq to SQL that's puzzling me and trying to understand what's happening. So I've taken the whole process procedurally in the hope of trying to find a resolution and have been unable to fix so far. Here's a repro of what is happening: Record change made to databas...

ADO.NET - Entity Data Model vs. LINQ To SQL

Hi guys, I am trying my best to understand what is the difference between "ADO.NET - Entity Data Model" and "LINQ To SQL", but I cannot figure it out. Can someone please explain the differences between the two and the advantages and disadvantages? Thanks Frank ...

How to merge two linq list queries of different type into list of new type?

I want to merge two lists of different types into one list of new type. I would use join, but if for example List A doesnt have a value for that common property, i still want to use the values for List B. class A{ decimal AValue DateTime Date int UserID } class B{ int BValue DateTime Date int UserID } class Merge{ decimal? A...

Show SQL generated by LinqtoSQL

How would one go about seeing the SQL generated by a LINQ2SQL insert? Let's say that I have db.Elephants.InsertOnSubmit(elephantInstance); db.SubmitChanges(); is there anyway to see the SQL? I've installed the LINQtoSQL visualizer Scott Gu mentions (http://weblogs.asp.net/scottgu/archive/2007/07/31/linq-to-sql-debug-...

Linq to SQL to append multiple records with a delimiter

Sorry for the bad title of the question apologies if it's a duplicate. I have two db tables: Users Documents ------- --------- ID ID Name DocumentName UserID Say I have 1 record in Users 1, "bob" and three related records in Documents 1, "Do...

with linq to sql dbml, how to get the size of a datatype? like varchar(50), how to get that 50?

with linq to sql(dbml file), how to get the size of a datatype? for an example, varchar(50), how to get that 50? thanks ...

Is there a LINQ equivalent of string.Join(string, string[])

Is there any way to convert a collection of objects into a single new object using LINQ? I want to use this within another LINQ to SQL expression. ...

What is the .cs file under MyDataContext.dbml for?

What is that individual (currently empty) file under MyDataContext.dbml for? Directory structure: Mydatacontext.dbml MyDataContext.cs MyDataContext.dbml.layout MyDataContext.designer.cs ...

number question

i hava a table below number 8789789 9080992 3213123 2143123 1312321 ....... ....... 1232123 almost 50.000 rows i want to get ordered numbers like 856620 856621 856622 856623 856624 856625 856626 856627 856628 856629 or 216350 216351 216352 216353 216354 216355 216356 216357 216358 216350 i want to get from table grouping 10 numbe...

C#: How to see if a Linq2SQL entity is in the database

I would like to check if an entity is already added to the database. So, how can I see this difference between a and b? var a = dataContext.Things.First(x => x.Name == something); var b = new Thing { Name = something }; To make it clearer, if I have this: var thing = dataContext.Things.FirstOrDefault(x => x.Name == something) ...

Things to be aware of when moving from LINQ to SQL --> LINQ to Entities

I have used LINQ to SQL successfully on an number of projects recently, but am keen to move to LINQ to Entities since this looks like the area that will be receiving more investment from Microsoft as they move to .NET 4.0 and beyond. Before doing so I am keen to find out what things LINQ to SQL has that are missing from LINQ to Entities...

with linq to sql, where is the database connection information stored?

Hi, With linq to sql, where is the database connection information stored? How could I override the database to another database on a per query basis? ...

Linq2SQL for a new project

EDIT Appreciate all the inputs guys. Opinions were very welcome, I think we'll go with an L2S implementation at this point and just roll-up/encapsulate our DAL in such a way that if we need to change to EF in the future, it won't be too painless an operation. As it was pretty subjective, points go to the poster with the most upvotes. ...

How do I use a transaction in LINQ to SQL using stored procedures?

I have a piece of code that looks something like this (ClearImportTable and InsertPage are stored procedures): datacontext.ClearImportTable() //Essentially a DELETE FROM table for (int i = 1; i < MAX_PAGES; ++i){ datacontext.InsertPage(i); //Inserts data into the table } This is a somewhat simplified version of my code, but the id...

Changing the Connection String of LINQ dmbl programmaticaly

I have two seperate databases, one is production the other is test. Before LINQ, I could simply change the connection string to swtich db's. However, the string is read only, and I have no way to change the string. How can I change the Connection String programmatically? Edited for Clarity Im using my.settings to store all of this inf...