linq-to-sql

Linq to Sql, batching stored proc requests

I have a db with sprocs, and it uses Linq to Sql's datacontext to access them. I believe that every time you execute the method call that represents the sproc from the datacontext it fires off the request to the database. I was wondering if there was a way of batching the requests, similarly to how the datacontext batches non-sproc cal...

Is clean SQL achievable on Linq to SQL?

Is clean (or should I say performant) SQL achievable in Linq to Sql? I wanted the Linq to Sql produce this code: SELECT C.CustomerID, COUNT(O.CustomerID) AS N FROM Customers C LEFT JOIN Orders O ON O.CustomerID = C.CustomerID GROUP BY C.CustomerID And I follow this code: http://stackoverflow.com/questions/695506/linq-left-join-group-...

SQL query that looks within the same table

Apologies - am not good at SQL. Perhaps this is a simple query - I don't know. What I have is a basic forum table - e.g. id poster title type content postedon parentID in this scheme, if a user asks a question, it is type = 0, and if it is an answer, type = 1. If the entry is an answer, I update the parentID to the id on the question...

Does Stackoverflow use Linq to SQL generated classes directly?

I wonder if someone knows whether Stackoverflow uses the classes generated by Linq to SQL directly in their application or how they do it. Thanks. ...

Creating methods that DO translate to SQL?

In the database of an application I'm using, there is a record that has a "Date" field. In many places in the code, we need to translate that into a Fiscal Year for grouping, selecting, and filtering. So here are a few examples of what a query might look like: var query = from r in DB.records let fy = r.Date.Month >= 10 ? r....

help with linq to sql many to many query

Hi I have following entities A_Entity ----------- AId AB_Entity ----------- AId BId B_Entity ----------- BId I have a function that helps in building the query based on the input provided. In this case I have to build a query to fetch all A_Entities that have matching BId (provided as input to the function) public static IQueryabl...

Self Referencing Many-To-Many Linq Query

I have a datatable like this: MtoM { ParentID, ChildID } Item { ID, Data, Label } How do I write a linq query that returns every ChildID under a given ParentID and the associated Data and Label for each of these decendent IDs. If I were using SQL I'd use a union all and inner join, but I don't know linq well enoug...

LINQ to SQL - Left Outer Join with multiple INNER JOINS

I am using multiple joins in a statement and Have tried to make linq-to-SQl query for this but no success. SELECT ur.UserName, ur.LandmarkRef, lt.Date, l.Place FROM tbl_Users ur LEFT OUTER JOIN tbl_LandMarks l ON ur.LandmarkRef = l.LandMarkID INNER JOIN tbl_LandmarkTypes lt ON l.LandmarkTypeRef equals lt.LandmarkTypeID ...

how to get Related Records using LINQ

Hello I have this table structure: **ProductsTable** ProductID ProductName **CategoriesTable** CategoryID CategoryName **ProductCategories** ProductID CategoryID Each Product can belong to multiple categories. Now I need a way to find Related Products. But I want it in this way: Let's say Product1 belong to Laptop, Accessories. So ...

Do we still need stored procedures when using compiled queries?

When using compiled queries in entity framework (or linq-to-sql) in combination with SQL Server, is there actually still any performance benefit in using stored procedures? Compiled queries will be cached as parameterized queries, so performance should be near equal to stored procedures. Is there any situation where stored procedures wo...

DataContext.Refresh not refreshing the object

I have a datacontext where I after communicating with the database performs the following operation: private DAL.Client _client; public void ReloadCurrentClient() { DBContext.Refresh(RefreshMode.OverwriteCurrentValues, _client); } I expected this method to bring the client-object back to sync with the datab...

LINQ to SQL where ID not in some_list

Hey, I'm trying to make a LINQ to SQL statement which filters results where the ID is not in some list of integers. I realise the .contains() method cannot be used in Linq to SQL but for the purposes of explaining what I'd like to do, here's what I'd like to do: nextInvention = (from inv in iContext.Inventions where...

Searchable Table - What would you do?

I'm trying to determine how to best design a storage facility for fast searching of text. There will be a different file format for each customer These files are XML, and the field names and attributes are not standard, and do not follow a schema The customer has an option to choose certain fields to be searchable There could be 100,00...

MS SQL Server 2008 Check Constraint, and LINQ-To-SQL

This is a tough question to word...so bear with me. I have two tables in my database, [Item] and [AssignedProperty]. [AssignedProperty] is the child in a parent-child relationship with [Item]. So it basically just has an ItemID field and a foreign key relationship utilizing it. [AssignedProperty] also has an identical relationship with ...

Linq-to-SQL or Linq-to-Entities with ASP.NET 3.5 and SQL Server 2005

I am starting a new project using C# and ASP.NET 3.5 with SQL Server 2005, and I am trying to decide which ORM is the best to use between LinqToSQL, LinqToEntities, or NHibernate. Ideally I would like to use the preferred Microsoft best practice; but I need to use a solution that will provide performance comparable to using stored proce...

What's the Oracle equivalent of System.Data.Linq.DataContext?

I am implementing the IRepository interface against an Oracle database. public interface IDinnerRepository { IQueryable<Dinner> FindAllDinners(); IQueryable<Dinner> FindByLocation(float latitude, float longitude); IQueryable<Dinner> FindUpcomingDinners(); Dinner GetDinner(int id); void Add(Dinner dinner...

varchar(max) + linq to sql

I've got a varchar(max) column I'm trying to read but the field is being truncated at 4,000 characters. I've seen similar questions, but they are on the sql side. What do I need to do to get the entire field? Eg: using (DataContext dc = new DataContext()) { var foo = dc.foos.First(); if (foo.Formula2.Length > 4000) { ...

Recommended approach to merging two tables

I have a database schema like this: [Patients] [Referrals] | | [PatientInsuranceCarriers] [ReferralInsuranceCarriers] \ / [InsuranceCarriers] PatientInsuranceCarriers and ReferralInsuranceCarriers are identical, except for the fac...

Linq to SQL concurrency problem

Hallo, I have web service that has multiple methods that can be called. Each time one of these methods is called I am logging the call to a statistics database so we know how many times each method is called each month and the average process time. Each time I log statistic data I first check the database to see if that method for the ...

MVVM with LinqToSQL

Hello Together, there a little BrainF*** question for me to understand MVVM in relation to LinqToSQL. The MVVM is build like: View --> Viewmodel --> Model View: the xaml and the cs code behind file. right ? Viewmodel: created by the Developer (*.cs), encapsulated properties of my Model Model: Datamodel So here is the Question: ...