linq-to-sql

Switch between development version and live version

Does anyone have any good techniques for easily switching between development and live builds for asp.net mvc websites? Every time I make some changes I need to change to go through my web.config and comment out all my local stuff and uncomment all my remote settings. I also need to update the linq-to-sql dbml file to point to the right ...

should linq to sql be used for websites that have high traffic

I have read many articles about linq to sql performance. The result which i got is it is slower than normal approach(DAL or Microsoft Enterprise library). Slower for both read and write operations even after performance tuning like disable ObjectTracking and other tricks. I know it has prons like quick development, clean code etc but wha...

Problem with insert in db with ASP.NET

Hello, i have problem with linq2sql. As you see below I have two tables from db - Dzieckos and Opiekuns. In Dzieckos i have idOpiekun. How to insert this idOpiekun like below, couse i have error in FK in example line. protected void btDodaj_Click(object sender, EventArgs e) { DataClassesDataContext db = new DataClassesDataConte...

Linq to SQL: How to get values added thru InsertOnSubmit but before SubmitChanges?

Hi, Having trouble getting this. I need get the values that I have added to a table entity through the InsertOnSubmit method. However I have not yet invoked SubmitChanges on the table. So, I have this in a loop: mdmDC.tblMDMListItems.InsertOnSubmit(listItemsTable); But I'd like to query mdmDC.tblMDMListItems for some values entered so...

databound checkbox list asp.net mvc and linq to sql

How do you create a databound checkbox list using linq-sql and asp.net mvc thanks ...

LINQ to SQL DataContext Caching

I am using Linq to SQL as my DAL layer and during unit test I found out that my objects are not being returned from database but from the DataContext cache. The strange thing is that when the objects are returned from the cache why does it require a separate call to the database to fetch all the fields. Anyway, I implemented a ClearC...

which LINQ statement is better and why

In both of the statement I am trying to fetch the ID of Catagory which has the name as specified in the variable; both work fine. What is the difference and which one is better string name = "Progreammers"; var categoryID = from c in DataContext.Categories where c.Name == name ...

Issues to consider when choosing data access technologies?

There were times when we had to choose between 2 or 3 technologies/strategies to develop modules. Now for every small or large component/module/project, we have almost uncountable options. It might be easy for those with years of experience, but not for those who are new to programming, say less than a year. I get frustrated sometimes ...

Where in Query with Array in LINQ

I have array number = {2,3,4,5,6} Now i have to select rows from table "dtlRecord" where this number is a column. Number count 2 10 3 23 4 20 So what i need is select sum(count) from dtlRecord where number in (2,3,4,5,6) group by number I need above query in LINQ to SQL ...

Group by on XML column field with LINQ

Is it possible to group by on field which contains XML data with LINQ? I am getting The XML data type cannot be compared or sorted, except when using the IS NULL operator.error. ...

submit partial changes to datacontext

Hi, is there a way to insert an entity without using the SubmitChanges() function of the datacontext? I want to do this because I have other changes done on my datacontext which I do not want to submit yet, if I call the SubmitChanges function it will submit all changes including the ones I do not want to save yet. ...

LInq-to-sql dynamic sorting problem

I have a linq-to-sql query over entity that has child entityset that I need to sort on some child fields, i.e. use this query: var query = from p in context.Patients let order = p.Lab_Orders.First() orderby order.Order_Date select p; This query runs fine, but how would I modify it to use DLIN...

Making a reusable predicate for EntitySet<T>, IQueryable<T> and IEnumerable<T>

In my LINQ to SQL setup I have various tables which are mapped to classes which basically support the same interface to support versioning, i.e. public interface IValid { int? validTo { get; } int validFrom { get; } } The LINQ to SQL classes derive from this interface like this: public partial class representationRevision : I...

LINQ entity data model generated code error - The type 'DBContexts.Category' already contains a definition for 'ID'

Hi, I have two tables in my database - Category and Department which both contain the same columns - ID, Name and Code. I can create a new entity model using the Visual Studio 2008 designer and add the Department and it works fine - I can query the database using LINQ, alls good. When I update the model and add the Category table, th...

Does Model Driven Architecture play nice with LINQ-to-SQL or Entity Framework?

My newly created system was created using the Model Driven Architecture approach so all I have is the model (let's say comprehensive 'Order' and 'Product' classes). These are fully tested classes that support the business of my application. Now it's time to persist these classes as objects on the harddrive and at some later time retrie...

Linq2SQL: DeleteAllOnSubmit discriminates entities being re-added?

Hi All, Encountering some weird behaviour with Linq: Situation: I have a many to many relationship between two entities: UserProfile and BusinessUnit (joined in UserProfile_BusinessUnit table). Using a ListBox, a user can multi-select BusinessUnits a UserProfile belongs to. When UPDATING the record, I call: dataContext.UserProfile_B...

why does my linq result show hex values in the debugger?

Hi I noticed when I look at say a result I got back from my database using linq to sql all fields like my primary key that is an auto increment field is shown as hex in my debugger. So like I will see in the debugger 0x00000006 instead of '6'. Is there any particular reason why? Kinda through me off guard when I wanted to take my resul...

Keep same selected Item in a ListView when the collection it is bound to is refreshed

I have a ListView that is bound to an ObservableCollection which is itself derived from an IQueryable. When I refresh the collection, after items are added, edited or a button is clicked (to see if the database has new items from other users). The listbox refreshes and selects the first item in the collection. I want to keep the same s...

How to use LINQ with stored proc in SQL to output xml

I am new to LINQ. I would like to execute a stored proc using LINQ and output to an XML file. How would I go about this? DataContext db = new DataContext(); var mysp = db.sp; now what, I want to keep the xml structure in the sp, currently I am running the sp without for XML auto, but my ideal results are with for XML auto in the proc....

LinqToSql how to implement calculated columns

I want to have a field in my entity where the returned data comes from a class function in mydomainservice and not from the database. The reason is that I want to generate an image URL (Silverlight bind) based rather loosely upon other fields in a table How can I obtain that ? ...