linq-to-sql

Linq to Sql Eager Loading Multiple Levels

Has anyone found a good workaround to the following linq-to-sql eager loading issues? http://www.lowendahl.net/showShout.aspx?id=190 I'm experiencing a similar issue where when trying to get back an object graph deeper than one level linq-to-sql generates an enormous number of round trips to the DB in order to handle a situation similar...

Dynamic LINQ2SQL to an unmapped table

I'm working with an application which allows customers to create and import custom tables. I have the need to allow those customers to build dynamic queries against the imported custom tables and I would like to be able to use LINQ to do this. I'm familiar with how to create Dynamic LINQ queries however all the methods I know of require...

LINQ to SQL Delayed Evaluation Exception Handling

I have a LINQ to SQL/Unity/ASP.NET MVC/SQL Server application hosted on Azure. I am using Lazy Evaluation throughout the whole site. The Application is using a TCP connection to SQL Server and every so often I get a "A transport-level error has occurred when sending the request to the server." SqlException. Well since the the query is ...

Where does a many to many relationship go in domain driven design?

In the model I currently have an interface as such: public interface IAmAnAssessment { int AssessmentId { get; set; } string UserName { get; set; } string DefectCode { get; set; } string AssociateSeverity { get; set; } string ShareholderSeverity { get; set; } string CustomerSeverity { get; set; } string RegulatorySeverity { get; ...

C# -Version Linq to Sql

From Linq to Sql i received the code (VB version) Dim db as New DBDSDataContext Dim products =_ <Products> <%=From product in db.Products_ Select_ <Product> <ProductName> <%=product.ProductName %> ...

Showing many tables in many dropdown lists. c#, asp.net-mvc, linq2sql

Hi, all I want to use an example to explain what I want. Assume I've following DB design: Item (id, name, categoryID); Category (id, name); When user wants to create an Item (fill in form), I'll give a list of categories in a dropdownlist, and when user chooses one of the categories ASP.NET MVC will automatically bind categoryID, to...

how to access to LinqToSqlcCasses from another application

hi, i want to have access to LinqToSqlClasses (mydbDataContext) class from another solution project. in fact, i can make an instanse of this class, but cant access to methods like SubmitChanges() and so on. please help me. ...

How can I dynamically create and save a LINQ-to-SQL object via reflection?

The following method creates a linq-to-sql object at run time based on a class name. I can also fill the properties of the item via reflection. But how do I save this object via the linq-to-sql commands if I don't know at runtime which type it is? public void CreateItem(string className) { //create instance of item string cla...

LINQ to SQL problem with bit/booleans

I'm having an issue with LINQ2Sql where the value in the database is not getting to my code correctly. Everything is OK except for columns defined as a bit field in the database. In my code after the LINQ query, the value for bit fields is always false. What the heck is going on? I've already tried deleting the table from the SQL desige...

Converting conditionally built SQL where-clause into LINQ

So I didn't see a question here that really answers this question. It's kinda a newbie question about linq but I would like to know if it would be possible to convert the following sql query (built using C#) into a linq query: public void DoSomeQuery(bool whereCriteria1, bool whereCriteria2) { string sqlQuery = "SELECT p.*"; str...

How to re-write this inner join subquery from SQL to Lambda

SELECT ulcch.ID, ulcch.UserLoginHistoryID, ulcch.StatusID, ulcch.ClientModuleID, ulcch.DeviceState, ulcch.UpdatedAt, ulcch.CreatedAt FROM UserLoginClientConnectionHistory AS ulcch INNER JOIN (SELECT MAX(CreatedAt) AS maxCreatedAt FROM UserLoginClientConnectionHistory AS ulcch1 GROUP BY UserLoginHistory...

search in LinqToSQLClasses

How can I search in a table if a record with specific parameter doesn't exist, and then insert the record into table? ...

Linq to SQL: getting old values of changed rows

I have an editable grid bound to a Linq to SQL table. I use SubmitChanges to save changes and I need a way to get old values of the changed rows. I tried getting context.GetChangeSet().Updates but the problem is the rows in this collection has new values not the old ones, even before calling SubmitChanges(). How can I do this? ...

Programmatically load a LINQ2SQL partial class

I am working on project that allows a user to add Time to a Task. On the Task I have a field for EstimatedDuration, and my thoughts are I can get ActualDuration from the Time added to the Task. I have a LINQ2SQL class for the Task, as well as and additional Task class (using partials). I have the following for my query so far: ...

Linq to Sql case insensitive equality

I am reading contradictory explanations on Linq to Sql string comparisons. When I do the following: from p in db.People where p.UserName=username select p username="jOHn" I get the correct case insensitive result. Is Linq doing this by default or is this happening in SQL database? ...

Conditional shortcuts in LinqToSql query

Here's a little LinqToSql GOTCHA: // Returns the number of counties in a state, // or all counties in the USA if the state is null public static int CountCounties(State s) { var q = from cy in County.GetTable() // my method to get the ITable where (s == null || s.Code == cy.StateCode) // shortcut OR operator, right...? s...

How do I disable LINQ to Sql transactions?

I want to make additions to a database, in this case massive amounts of information, with no transactions on my LINQ To SQL model. Does anyone know how to turn off LINQ To SQL transactions on a datacontext or on the submit changes operation? ...

remove column from variable (LINQ)

hi, I have defined the following variable var result = from report in firoozehDataContext.Reports select report; now if i want delete One of the columns in the variable, how do i it? ...

LINQ to SQL throws exceptions when stress tested

I have this web app that is running ASP .NET MVC 1.0 with LINQ 2 SQL I'm noticing a very strange problem with LINQ 2 SQL throwing exceptions (mainly Specified cast invalid or Sequence contains more than one element) when under a certain amount of load. The bigger problem is, I'm not talking about Real Heavy/Professional Stress Testing....

How to deal with DateTime field when using LEFT OUTER JOIN in LinqToSql

Hi, I have 2 tables, Employee and Absence. I want to do a left outer join so that I get all employees and any associated absences. In LINQ2SQL I can use the following to create the LEFT OUTER JOIN: from e in Employees join a in Absences on e.EmployeeID equals a.EmployeeID into ae from x in ae.DefaultIfEmpty() select new { FullName = ...