linq-to-sql

LINQ to SQL using GROUP BY and COUNT(DISTINCT)

I have to perform the following SQL query: select answer_nbr, count(distinct user_nbr) from tpoll_answer where poll_nbr = 16 group by answer_nbr The LINQ to SQL query from a in tpoll_answer where a.poll_nbr = 16 select a.answer_nbr, a.user_nbr distinct maps to the following SQL query: select distinct answer_nbr, distinct user_n...

Why is IEnumerable.Count() capped at 200?

Is there a limit to the rows that IEnumerable.Count() (or IQueryable.Count()) using LINQ to SQL? For whatever reason, if my query returns more than 200 records, I only get 200 from IEnumerable.Count(). I've even tried using IEnumerable.LongCount() (even though the number of results shouldn't be high enough to need it). I've also verif...

Getting weird exception creating anonymous type after recreating Linq to SQL dbml (Or possibly after moving to .NET 3.5 SP1

We moved the .dbml file out of the website and into another assembly so it could be shared across multiple applications. The problem is that now I'm getting an error that doesn't make any sense. The basic query is like this: from D in Devices select new { EquipmentTypeID = D.DMXDeviceModel.DMXDeviceClass.DMXEquipmentType.ID, /...

LINQ to SQL-- Best learning resources?

It's not that I can't google for myself, however others have tread this path before me and I"m always interested in what other programmers have found helpful, or not :) Thanks in advance for any input. ...

Which versions of SQL Server does LINQ to SQL support?

Can SQL Server 2000 be used as the database for LINQ to SQL? Does LINQ to SQL rely on a specific version of Microsoft SQL Server? ...

LInqToSql and errors when a debugger is attached

I am using LinqToSQL to grab data from my database. I am injecting my DBContext into the application using Springs IOC container. If I dont have my VS debugger attached, it works fine. However, with the debugger attached I get the following errors: "There is already an open DataReader associated with this Command which must be closed...

Return IQueryable containing 2 Subclasses

Can you return IQueryable which is composed of two or more different subclasses ? Here's my attempt to show what I mean. It throws the error: System.NotSupportedException: Types in Union or Concat have members assigned in different order.. var a = from oi in db.OrderItems where oi.OrderID == ID && oi.ListingID != n...

Howto undo ChangeSet in LINQtoSQL

Hi, in my data layer class I have created a function to manually refresh the data source. Public Sub DiscardAllChanges() _Context.Refresh(RefreshMode.OverwriteCurrentValues) End Sub The problem is that the context ChangeSet after this operation still trace the previous operation of Insertion, Deletion and Update that I made call...

What should I use instead of Linq to SQL?

I've been reading about how Linq to SQL is dead (link here). So my question is what should I use instead? I already have a project full of Linq to SQL. What's the best thing to migrate it over to? ...

Doesn't Linq to SQL miss the point? Aren't ORM-mappers (SubSonic, etc.) sub-optimal solutions?

I'd like the community's take on some thoughts I've had about Linq to Sql and other ORM mappers. I like Linq to Sql and the idea of expressing data access logic (or CRUD operations in general) in your native development tongue rather than having to deal with the "impedance mismatch" between C# and SQL. For example, to return an ObjectD...

Linq to SQL Queries determined at runtime

The number of query conditions is determined by user selections at runtime, ie var results= from r in db.Table where condition A && condition B && ... condition XX... Is the best way to handle this to build a string variable and append to it or is there another way? ...

How to share a key between Global.asax and a Page in Asp.Net

hello all, I'm working with linq to sql, and therefore need to store my DataContext for future use for each thread (I've read this article: http://www.west-wind.com/weblog/posts/246222.aspx regarding ways to implement a shared context). What I want to know though, is how do I create a single key that both the global.asax file will know...

SQL CLR Objects for Heavy Operations

Here is my scenario: I have implemented set logic in my C# framework. Sets can contain a large quantity of objects, perhaps even up to 1 million in the worse case. Assume sets just contain lists of objects called Doc. Because of the potential large number of objects, I would like to give the developer a choice of how to create and us...

CommunicationException on Asynchronous callback for web service called from Silverlight app.

Hey all, I am working with another coder on a website that is accessing SQL Server (2008 Express) through some web services he created (involving mostly LINQ to SQL), and the UI is in Silverlight. I've been working on another part of the system, but just got his latest code, and am trying to run it on my machine, but am getting an erro...

Linq To Sql return from function as IQueryable<T>

Ok, I have managed to get the following working public IQueryable getTicketInformation(int ticketID) { var ticketDetails = from tickets in _context.tickets join file in _context.file_objects on tickets.ticket_id equals file.source_id where tickets.ticket_id == ticketID select new { tickets.ticket_id, tickets....

Linq to Sql and the Repository Pattern.

I feel like I'm running around in circles. I can't seem to make up my mind as to what the right Repository pattern is using Linq To Sql. If you're familiar with Rob Conery's MVC Storefront you will see that his implementation wraps the Linq-Generated models with another class and treats the Linq-Generated one simply as a Data Transfer Ob...

Using Linq to SQL and Sql Reporting Services

I have a question regarding the integration of business objects developed using Linq To Sql for data query and integrating with Sql Server Reporting Services. We have a set of business objects that query a couple of back end databases that is developed with Linq to SQL. The SQL that gets generated is relatively dynamic (based on the con...

linq to sql and retrieving only specific rows from joined tables

I have two tables 1) Product 2) Categories Product table has a field called "CategoryID" and the Category table has a field called "CategoryName", ID, DateCreated, and a few others. I want to use LINQ to SQL to query all the Product rows as well as JUST the Category.CategoryName. This query will be used in a datasource and be bound to ...

How can I query hierarchies with LinqToSQL?

I have a hierarchy that I'd like to query with LinqToSql: Country -> Region -> City -> ZipCode Each entity holds both a reference to it's parent (eg. Region.Country) and a collection of it's children (eg. Region.Cities). I'd like to eager load each entity's parent along with Countries and Regions but lazy load cities and zip codes. T...

Linq to SQl query extensions

query = query.Where(m => m.People.Contains(s)).Select(m => m).ToList(); In the above, "People" is an IList of strings. IF I replace People with a list of objects with string as a field of that object, how do I get the same results. ...