linq-to-sql

Is it possible to use Linq-SQL without drag-and-drop?

If i want to use Linq-SQL i also have to drag the DB Table unto the designer surface to create the entity classes. I always like full control in my application and do not like the classes created by dotnet. Is it possible to provide this connection between Linq and the DB using my own Data Access Layer Entity classes? How can i get i...

Recommended approach for linq to sql serialization for simple json and mvc

I have cascading drop down lists in a .net mvc view and am using JQuery onchange to pull the next drop down list using a json response. The problem comes in where iI get a circular reference when trying to serialize the linq to sql response. I understand why it is happening, its because I have the buyer -> contracts and contract -> b...

Problem with Updating an Entity with a Timestamp Column via WCF

We're trying to update an entity via WCF, and the entity contains a Timestamp column. When we attempt the update, we get the following Data.Linq error, "A member that is computed or generated by the database cannot be changed." This message is referring to the Timestamp column. If we attempt the very same update not using WCF, it works ...

How do I join on a constant in LINQ?

I'm trying to do a left join on a constant like this: SELECT [t0].[DeviceId], [t0].[DeviceTypeId], [t0].[UnitId], [t0].[UnitNum], [t0].[ManPhone], [t0].[Status], [t2].[MaintDate] AS [ServiceExpiration] FROM [dbo].[Devices] AS [t0] INNER JOIN [dbo].[CustomerDevices] AS [t1] ON ([t0].[DeviceId]...

Linq-To-SQL Legacy Relation Mapping

Hi, I am trying to get Linq2SQL to work with my legacy database. I currently have a notes table that is generic to a few different entities and mapped m:m. Instead of mapping one relation table per entity type whoever designed this database decided to use a single relation table with a type column (as a varchar yuck!). How do I map F...

How Do I Show images on Asp.Net Website with Linq Query?

i can add images without any problem to my website.with my below code..i am using linq and asp.net with c#.... ImageDatabaseDataContext imdb = new ImageDatabaseDataContext(); Dosyalar ds; Katilimci kt; protected void btnEkle_Click(object sender, EventArgs e) { if (FileUpload1.FileContent != null) { string dosyaAdi = Guid...

How can I define a parameterless constructor in a partial LINQ-to-SQL class?

I have a LINQ-to-SQL class called Task. I also have a partial class called Task which adds methods to its functionality: public partial class Task : Item {... However, now I want to execute code when a Task object is constructed but if I had a constructor: public Task() { ... } it tells me: 'TestApp.Models.Task' already d...

combining linq queries

Hi, i have a couple of linq queries which I wanted to join var IDs = from p in ctx.bam_Zending_AllInstances where p.Zender == "RT30" select new { Identificatie = p.Identificatie }; var latestIDs = from p in ctx.bam_Zending_AllInstances w...

Converting IQueryable<object> results to comma delimited string

Hi, I have a LINQ query that returns all absences for an employee. The first part of the linq statement gets a basic list of the employees details, but I also return an IQueryable list of illnesses related to that absence. I'd like to somehow convert that IQueryable list to a comma delimited list of Illnesses. Currently I use (majorl...

Why does this LINQ-to-SQL query get a NotSupportedException?

The following LINQ statement: public override List<Item> SearchListWithSearchPhrase(string searchPhrase) { List<string> searchTerms = StringHelpers.GetSearchTerms(searchPhrase); using (var db = Datasource.GetContext()) { return (from t in db.Tasks where searchTerms.All(term => t....

Auto Suggested Text Box with concatenated string with LINQ to SQL

Hi, I'm creating a text box with auto-suggested. So, it works well. It suggests only first name, but I want it to suggest the full name (first and last name which two different columns). Take a look at the following code behind that worked as expected : <System.Web.Services.WebMethod()> _ Public Shared Function GetNames(ByVal prefixTex...

Is Typemock the only framework that can mock a Linq To SQL Table class?

I am trying to setup unit tests for my Linq To SQL code. My code uses the System.Data.Linq.Table class (generated by the designer). Because this class is sealed and the constructor is internal it is completely impervious to unit testing frameworks like Rhino Mocks. (Unless you want to alter you code to use the repository pattern, whic...

Really complex LINQ (to SQL) query example

We're thinking about adding more LINQ tests for ORMBattle.NET, but have no more ideas. All LINQ tests there are checking common LINQ functionality: Any test must pass on LINQ to IEnumerable For any test, there must be at least one ORM, on it passes (actually it doesn't matter if it is listed @ ORMBattle or not). Currently the goal of...

Linq2SQL: "Transaction (Process ID 56) was deadlocked on lock resources with another"

I have a process that (at night) take a large chunk of data in the form of a linq2sql query and dumps this as XML (sitemaps). My problem is that I'm sometimes is getting: System.Data.SqlClient.SqlException: Transaction (Process ID XX) was deadlocked on lock resources with another process and has been chosen as the deadlock victim. Rerun...

Database transaction timeout problem

I have been experiencing an error that I believe is caused by the database timing out due to a large amount of data being processed and read to the database. I keep getting this error message: Distributed transaction completed. Either enlist this session in a new transaction or the NULL transaction. I timed how long it takes t...

sorting of an Iqueryable

I have an IQueryable with duplicate entries and I want to sort this IQueryable by the count of occurrences. ...

LINQ to SQL equivalent for XML file persistence.

Microsoft has made saving objects very easy with their LINQ to SQL mapping. However, I would sometimes like something a little more lightweight, i.e. the ability to save objects to a file when an application closes, and read them back in again. XML seems like a natural data format rather than inventing a new data format. (Of course, on...

Architectural Design DAL Layer

I am working on architecture of mid sized web application & for my DAL layer i am having 3 options 1) Traditional Stored proc Based Architecture (Using NTiers Template of Codesmith) 2) LINQ To SQL (or PLINQO Template of codesmith) 3) LINQ To Entity From above LINQ to Entity is out of reach as we need to start application very quickl...

Which ORM tools support this version of Queryable.Select extension method

Do you know an ORM supporting this extension method: public static IQueryable<TResult> Select<TSource, TResult>( this IQueryable<TSource> source, Expression<Func<TSource, int, TResult>> selector) Basically, it allows to add row number (index of result in sequence) to the projection. Example of its usage with IEnumerable is here. ...

ASP.NET Membership and Linq to SQL

I am wondering the best way about setting up asp.net membership in sql server to work well with linq to sql. I'd like to use the username field for the foreign key relationships and have linq to sql recognise the asp user property. I am having some problems getting relationships right between the users table and my other tables. Do I n...