linq-to-sql

LINQ options.loadwith problem.

I am writing a tag-based ASP.net system. Using the following db scheme: Topic <many-many> TagTopicMap <many-many> Tag Basically it is a 3NF approach (toxi) that I found from the following: http://www.pui.ch/phred/archives/2005/04/tags-database-schemas.html Here is the code snippet I have: DataLoadOptions options = new DataLoadOptions...

What technologies to use for starting up a new project? (Technology Prespective)

Hey Guys, Today I had a nice opportunity from my manager to propose new technologies to start up a new project. Here we used to use ASP.NET and SQL mainly. I really wanna propose using ASP.NET MVC and LINQ To SQL and do some nice TDD. The question is, i don't know how to convince my manager, actually i'm not sure of these choices mysel...

How to databind a Linq2SQL collection to winform textfields

Hi, I am a little bit puzzled as to how I can optimize my program by utlizing DataBindings. My program uses several Linq2SQL bound Objects storing the Data. All ORM objects are stored in a hierarchy. In a second GUI project I am displaying this data in some Text and Combo Box fields. The data structure hierarchy is as follows: JobMan...

Why is my SqlCommand returning a string when it should be an int?

I have a query that should always be returning a single int. I have now logged it returning a string entirely unrelated to what it should be. We've been getting some random FormatExceptions that we've tracked down to several database queries. After some additional logging, I found that, this morning, the query below returned the string ...

Mapping Linq-to-Sql entities to custom domain entities

How could I map my Linq-to-Sql generated entities (DTO’s) to my domain entities? The problem is that I can’t map the associations because they are not of the same type. The DTO’s uses EntitySet and EntityRef and my domain entities uses IList and T. I’ve looked at some blog post: Ian Cooper's architecting-linq-to-sql-applications-part-5 ...

How to make Linq to SQL translate to a derived column?

I have a table with a 'Wav' column that is of type 'VARBINARY(max)' (storing a wav file) and would like to be able to check if there is a wav from Linq to SQL. My first approach was to do the following in Linq: var result = from row in dc.Table select new { NoWav = row.Wav != null }; The problem with the code above is it...

Deciding on a database structure for pricing wizard

Option A We are working on a small project that requires a pricing wizard for custom tables. (yes, actual custom tables- the kind you eat at. From here out I'll call them kitchen tables so we don't get confused) I came up with a model where each kitchen table part was a database table. So the database looked like this: TableLineItem --...

Testing Linqto SQL classes

How do I unit test my code that has LTS Datacontext. I get error while testing, I have a lot of Datacontexts and manually adding the Connection string is a pain, any suggestions. ...

converting group SQL expression into LINQ

Hi guys! I am having a real pain in converting this query expression into my LINQ expression. SELECT r.Disc_code ,r.SEX FROM RACE r WHERE r.EVENT_CODE = 100 GROUP BY r.SEX , r.disc_Code order by r.disc_code i can work with one table but i have not seen any example which chains two group expressions in stackove...

Perform .Select() on IQueryable with List of Func<T, string> delegates.

First of all, let me apologize in case the title doesn't make sense. I'm having a hard time understanding what I'm doing, let alone being able to use the right words for describing what I'm doing. I'm building a generic grid class in which I define the columns by a header / linq expression combination: public class Column<T> { publ...

LINQ to SQL and get Association values from dbml file

I have a dbml file that was autogenerated. I want to, in code (VB.Net) get the Association values for one of the properties. How is this accomplished? Basically, in my vb.Net code I'd like to somehow know (in the following example) the LookupDocumentStatus.IsForeignKey and the LookupDocumentStatus.ThisKey value. Is there an easy way to...

Linq2SQL check if item is null

Hi all foreach (var incident in new DataAccess.IncidentRepository().GetItems().Where( i => (startDate == null || i.IncidentDate >= startDate) && (endDate == null || i.IncidentDate <= endDate) && (shiftId == null || i.ShiftId == shiftId) && (processAreaId ==...

LINQ to SQL deep copy object with dependencies

I am trying to create a list of LINQ to SQL objects which i will add to the datacontext and insert later. When i do call SubmitChanges() though I get an error saying the Postcode foreign key for the WeatherForecast object is null. I appears that when List.Add() is called it doesn't do a deep copy of the dependent objects. Is there anyw...

How to select across a relationship using LINQPad?

I have a simple table structure Images(image_id, image_library_id,...) Links(link_id, image_id, link_component_code...) I am trying to perform a simple query using LINQ var q = from i in Images where i.Link.link_component_code = "x" select i; However the intellisense in LINQPad doesn't provide the "Link" object in where i.Link.li...

Can you include linq-to-sql changes and ADO.NET dataset table adapter updates in a single transaction?

Here are the relevant technologies that I'm working with: Devart's dot Connect for Oracle (to facilitate Linq-to-Sql for Oracle). Strongly Typed ADO.NET Datasets. An Oracle database. Here's the challenge: My legacy code submits database updates with ADO.NET datasets and table adapters. I'd like to begin converting that code over to...

linq to sql inserting an entity after creating in memory

I'm building a booking engine for a car hire place. I have a Booking l2s object, which has a Car and Location objects (and subsequent FK CarID / LocationID fields). During the first step of the booking process, I new up a Booking() class. This is passed along in a session to the subsequent pages. As the user proceeds through the proce...

Linq to SQL

Possible Duplicates: Is LINQ to SQL DOA? I am starting a new ASP.Net project which holds all data in a SQL database. I would normally use Linq to SQL to do all my queries, updates and inserts. but as i recently found out Microsoft will no longer develop/support Linq to SQL. What would you use as an alternative? Does anyone know...

better way of linq multiple joins?

Hello, Here is what I am trying to do: I have three tables, manifest, details and billingJournal for each manifest there are details and may be a billingJournal entry or not, if there is and it has the field recordType = 1 then billingJournal.amount is the billing amount and I need it in my grid also. I currently am doing a two step ...

LINQ DeferredLoadingEnabled & DataLoadOptions relationship

Hi, I have had a road-block that has cascaded itself down to the situation described below. I haven't had much help with people answering my previous questions, (i think i have to learn to frame them better) but i hope someone can at least explain this to me (i am a newbie to LINQ and haven't had an opportunity as yet to read into it a...

Convert SQL Query back to Linq Expression programmatically

Is it possible to somehow programmatically convert a sql query to a linq expression tree? The sql query is supposed to be generated by this linq query, so I'm thinking of it as a poor man's serialization\deserialization of linq queries to t-sql format. Thank you. ...