linq-to-sql

LINQ with SQLite (linqtosql)

I have a small project that require a storage (I choose SQLite) and I got good result with the ADO DLL for .Net for Sqlite. After the Install, I noticed that it contain a SQLLinq.dll. Before investigating too much effort, and because I haven't see any good example on the web, I would like to know if anyone got any good result with SQLit...

Linq to SQL Class - Stored Procedure Signature Change

I have a Linq to Sql .dbml file which auto generates my method signatures for certain stored procedures. eg, I have in SQL spGetEmployees(@Name) so in my data context I have spGetEmployees(string Name). Now, my underlying sp changed to add an additional parameter: spGetEmployees(@name, @count) and so I want the function in my DataConte...

Why use a web service with Linq to SQL?

Can anyone tell me what the need/advantage is to using a web service with an asp.net gui and using Linq to SQL? The web service layer seems unnecessary. Linq to SQL is completely new to me and I am researching as I am setting up a new project. Does anyone have any experience with this? ...

Fetching items which has a specific set of child elements (advanced query - possible?)

Hi, I have a SQL database (SQL Server 2008) which contains the following design ITEM ID (Int, Identity) Name (NVarChar(50)) Description (NVarChar(200)) META ID (Int, Identity) Name (NVarChar(50)) There exists a N-N relationship between these two, i.e an Item can contain zero or more meta references and a meta can be associated ...

Is LINQ to SQL Dead or Alive?

Just when I make friends with LINQ to SQL, it appears as though MS is pulling the rug out from under it. http://blogs.msdn.com/adonet/archive/2008/10/29/update-on-linq-to-sql-and-linq-to-entities-roadmap.aspx From my little bit of research, EF is way overkill for simple work. But after this announcement is there a point in continuing ...

How do I do a many-to-many relationship in LINQ?

I have two tables say, t1 and t2 that have t1.t1_id and t2.t2_id as primary keys. They are related by table t3 with columns t3.t1_id and t3.t2_id, respectively. Using LINQ I get an EntitySet<t3> on class t1 and t2, but what I want is an EntitySet<t2> on class t1 and EntitySet<t1> on class t2. How do I do this? ...

Best primary key data type for Linq to SQL

I am starting new project with SqlServer and Linq to Sql. What data type would be better for surrogate keys in tables: identity or uniqueidentifier ? As I understood, identity is automatically generated on insert, while uniqueidentifier should be generated in code (GUID). Are there any significant performance differences? e.g. ident...

How can I return a joined table as an enumerable on an anonymous return type in linq to sql?

I'd like to return an object with the following signature class AnonClass{ string Name {get;} IEnumerable<Group> Groups {get;} } I have tried the following query, but g only returns a single entity, not all the joined entities var q = from t in dc.Themes join g in dc.Groups on t.K equals g.ThemeK select new {t.Name, Groups =...

Can take be used in a query expression in c# linq instead of using .Take(x)?

I'm trying to write some LINQ To SQL code that would generate SQL like SELECT t.Name, g.Name FROM Theme t INNER JOIN ( SELECT TOP 5 * FROM [Group] ORDER BY TotalMembers ) as g ON t.K = g.ThemeK So far I have var q = from t in dc.Themes join g in dc.Groups on t.K equals g.ThemeK into groups select new { t.Name, Groups = (fr...

LinkDataSource can't load DataContext

I am trying to populate a dropdown list control on an web page using VS 2008 and keep getting an error that it can't load the DataContext. My backend is a SQLx server 2005 DB. I create a Link To SQL data context and have 1 table in it. My LinKDataSource is as follows - asp:LinqDataSource ID="LinqDataSource1" runat="server"ContextTy...

Linq To Sql vs Entity Framework Performance

I have been searching for recent performance benchmarks that compare L2S and EF and couldnt find any that tested calling stored procedures using the released version of EF. So, I ran some of my own tests and found some interesting results. Do these results look right? Should I be testing it in a different way? One instance of the conte...

Advice on removing multiple sub-queries (which contains a join) by optimizing Linq To SQL query

I'm working on adding globalization to my product cataloge and I have made it work. However, I feel that the underlaying SQL query isn't performing as well as it could and I could need some advice on how to change my Linq To SQL query to make it more efficient. The tables that are used Product contains a unique id for each product. Thi...

Best-practices for localizing a SQL Server (2005/2008) database

Question I'm sure many of you have been faced by the challenge of localizing a database backend to an application. If you've not then I'd be pretty confident in saying that the odds of you having to do so in the future is quite large. I'm talking anout storing multiple translations of texts (and the same can be said for currency etc.) f...

How should I get started learning about ADO.NET Entity Framework?

So here I am just about to start a big project using LINQ to SQL and then I read this: Is LINQ to SQL Truly Dead? by Jonathan Allen for InfoQ.com Well, I don't want to be supporting LINQ to SQL indefinitely if it's a dead end. So, how should I get started learning about ADO.NET Entity Framework? ...

How can I reject all changes in a Linq to SQL's DataContext?

On Linq to SQL's DataContext I am able to call SubmitChanges() to submit all changes. What I want is to somehow reject all changes in the datacontext and rollback all changes (preferable without going to the database). Is this possible? ...

Problem using LINQ to SQL with one DataContext per atomic action

I have started using Linq to SQL in a (bit DDD like) system which looks (overly simplified) like this: public class SomeEntity // Imagine this is a fully mapped linq2sql class. { public Guid SomeEntityId { get; set; } public AnotherEntity Relation { get; set; } } public class AnotherEntity // Imagine this is a fully mapped linq2sql c...

Adding Nodes to Tree via LINQ creates "query operator not supported" during runtime

I am trying to get my head around a LINQ issue. The ultimate goal is to load tree view with data acquired from LINQ to SQL (view). The issue is when I try to access the data acquired it keeps throwing a "query operator not supported during runtime". The code involved is no more than: Dim tasklistdata As New lqDataContext Dim Use...

How do I use 'Order By' to sort on a property of an inherited type in LINQ-to-SQL?

Hi, I have a fairly standard inheritance situation in my current LINQ-to-SQL project. I have a base class called 'Party' and classes called 'Individual' and 'Organisation' which inherit from it. What I want to achieve seems (and probably is) fairly simple. I want to return a list of 'Organisations' sorted by Company Name. The problem i...

Linq to Sql entity associations (non integer primary keys)

I've been playing around with Linq to Sql, but i've come accross a problem when defining associations between entities. I have 2 tables, 1 is a table containing customer transactions and the other is a lookup table containing transaction types. For example, a transaction can be type 'CASH' and the value in the lookup table will have a p...

Obtain max length for a "string" column using LINQ To SQL

Is it possible to obtain the maximum column length for a VARCHAR, CHAR etc? ...