linq-to-sql

How and where in VS2008 I can see my Linq comands being translate into Transact-SQL statements?

Hello, Linq commands are translated into transact-sql statements. I've VS2008 professional. How and where can I see how this majic happens? (by debugging?) EDIT Let's say I have this var allProducts = db.Products; I guess this will be translate by SELECT * FROM Products Where can I look at to see that? For instance, when I debug...

Extension points in Linq-to-Sql

Are there more extension points available in linq-to-sql than creating your own partial DataContext class and extension methods? Update: To be more specific: I want to collect the extension points that are available in Linq-to-Sql, because I thought it would be interesting to know were you are able to step into the codegeration. At the...

LINQ Equivalent of SQL

I have to translate the following SQL Query into LINQ equivalent SELECT 0 AS DOCID, 'All_Forms ' as PAGE, 0 AS PAGENUMBER UNION SELECT DOCID, (CAST(IsNull(CUSTOMPAGE,PAGENUMBER) AS VARCHAR(10)) +'. '+TITLE ) AS PAGE, PAGENUMBER FROM Medical_Reports WHERE PAPERSTYLE='Normal' AND PAGENUMBER<>10000 ...

Linq to SQL: Updating an aggregate root

I have an object with nested parts persisted over three tables. The classes are POCO with IList<> for relations. No ties to any framework. A_object-> B_object[N]-> C_object[N] I send this object to a repository to update. The repository persists content using Linq to SQL. myRepo.Update(A_object); The first loop that handles upda...

Problem with stored procedure in LINQ-to-SQL

Hi all, I'm having a never-ending problem with trying to call a stored procedure from a controller - if I could I'd add a bounty to this as it's taken way too much time already and I don't know what else to do (but I don't have the points). Based on my research it seems it's a known bug, but not of the workarounds have worked for me so I...

Linq to SQL: Why "This SqlTransaction has completed; it is no longer usable."

I have three tables related to each other. They represent a hierarchical object. A_Table-> B_Table -> C_Table I drilled my error down to setting the primary key values to their same values as before. When I SubmitChanges(), it fails after about 30 seconds with an error of: "This SqlTransaction has completed; it is no longer usable....

Linq custom comparer for contains?

I have 2 lists. I want to compare every element with every element for both lists using LINQ (versus using say a nested loop). But, the Contains does not meet my needs because I need to do a custom comparison. I would imagine a custom comparer is what I need but not 100% sure. I do not think this should be too difficult but not sure exa...

Why Invalidate() should be called outside the control then it can work ?

I am using C# + winforms to develop software. I have a UserControl which contains several DataGridView datagridview1.datasource = from p in dc.doctor select p; I use linq to sql to populate the dataGridView with dataSource, because I need to refresh the datasource to update the records, so I create a new dataContext and assign the d...

Getting MVC2 Delete to work.

Ok i have an mvc app. and im trying to get my delete to work. Basically i want it so when i click delete it takes me to a page saying "are you sure?" i have that working, the problem is catching the request and actually doing the delete. i tried diffrent methods. as below. public ActionResult Delete(int id) { var something...

Error when trying to create a partial class.

I have created a Area class using Linq-to-SQL. Now I want to create a partial class of the same name so I can implement validation. Any help? Error 1 Cannot implicitly convert type 'System.Data.Linq.Table<SeguimientoDocente.Area>' to 'System.Linq.IQueryable<SeguimientoDocente.Models.Area>' C:\Users\Sergio\documents\visual...

Why does this query timeout?

I have a L2S query with several joins that should returns 11 records in about 3 seconds. However, it times out after 30 seconds unless I specify a Take parameter (i used Take(20) even though it only returns 11 records) in which case it returns in the expected time frame of 3 seconds with the 11 records. The query looks like this: (fro...

linq to sql ToList() method value

when there's no rows returned from the database. Will I always get a List object of Count = 0. Will there ever be a case where the List = null? ...

C# - Serializing and Deserializing Linq Tables whilst maintaining Relationships

Hi All, I want to Test my code! A noble goal I'm sure you agree. I need to mock out DataContexts for my Regression tests, running the test will verify that for any code change, given the same input we produce the same output. I'm using Moles to mock out my data contexts. It's awesome and simple, I recommend it, I might move to Moq if ...

extending SqlMethods.Like to support property name

I'm trying to extend SqlMethods.Like method to support property name rather than property value, i wrote the following extension method : public static bool Like(this object obj, string propertyName, string pattern) { var properties = obj.GetType().GetProperties().Select(p => p.Name); if(!properties.Contains...

Help! Checking if a field is empty.

I'm using Linq-to-SQL as my ORM on a ASP.Net MVC2 application. I have a table called Area which is related to the Jefe table. In my application, I don't want users to write down a value in the IDJefe field, but rather select from a combobox. Should I ask if string.NullorEmpty for (IDJefe) or (Jefe)? Both of these properties are availab...

Left Join on Table with One-to-Many relationship

My apologies in advance for the haziness here, but I find this problem somewhat difficult to explain (although I'm sure it's a fairly common problem/solution). I want to execute a query selecting rows from a table joined with another table where the other table is the "many" in the one-to-many relationship. But one of my where clauses n...

Problems submitting DataGridView changes with Linq-to-SQL

I'm trying to implement database value edition through a DataGridView control but honestly I'm having a hard time trying to accomplish that. I'm basically using LINQ-to-SQL classes and events, the following being the most significant snippets: var data = from q in data.FOOBARS select new { ID = q...

Can't load a DropDownList with values.

I'm following the NerdDinner tutorial while building my own application. The tutorial gives this: public ActionResult Edit(int id) { Dinner dinner = dinnerRepository.GetDinner(id); ViewData["Countries"] = new SelectList(PhoneValidator.AllCountries, dinner.Country); return View(dinner); } My code is like this: public ActionResult ...

When assigning values to EntityRef ID fields in Linq to Sql, can EntityRef still delay load?

I've got an ASP.NET MVC app that uses Linq to Sql for data access. Say I have two objects: An Order object that has a foreign key to a Customer object by CustomerID. So, in my Order class, you would see two properties: an int CustomerID field, and an EntityRef member accessible by a Customer property. When the edits or submits an Or...

Can LINQ To SQL detect where a table association breaks?

I have two tables I am using to fill a gridview. The tables have a common field named RangeActivityID. My problem is that the database is very old and some of the older entries do not match up IDs between tables, so I am unable to add an association between them in the database. I do not care about the old data which doesn't match up, ...