linq-to-sql

system.LinQ.Iqueryable(of date) cannot be converted to date

Hello, I am trying to fetch data using linQ as shown below. dim rerun as datetime Dim q = (From a In dashboard Where a.SucessFlag = 0 And a.ApplicationID = 1 _ Select a.logDate) rerunDate = q I am getting this system.LinQ.Iqueryable(of date) cannot be converted to date Any workaround ...

Can Linq-To-Sql be aware of similarities of two tables?

Imagine I have 2 tables in my database, with the same schema (columns, types, etc). Can Linq-To-Sql treat them as Table<AClass> using the same class for both of them? How to do it? ...

Multiple Sorting on LINQ (nested) method

I have the below LINQ method which gets called from a User Control and dumped straight to a standard DataGridView. My users want it default sorted, first, by DisenrollmentDate and then, Member Name. Right now, with the code below, it sorts by DisenrollmentDate ONLY. BLLCmo.cs public static DataTable GetAllMembers(Guid workerID)...

Returning Every Other Record with LINQ

I have a query that returns 10000's of records that are used as plot points on a map. In an effort to reduce load, and increase app speed we're trying to implement what basically amounts to Level of Detail logic. Basically, when zoomed out, display 50% of the points. When zoomed in, display 100% of the points. This is ultimately what I ...

Nested LINQ Method throwing a `Not Supported...` Exception

This is a follow up from here -->multiple-sorting-on-linq-nested-method . Basically, on let memberName = ... it is throwing this exception Method 'System.String MemberName(Int32)' has no supported translation to SQL. and I am not figuring out the solution. Also, BLLCmo and BLLConnect actually use TWO different DataBases. The original ...

Is it possible to extend Visual Studio Linq-to-Sql designer to support geometry types?

According to this blog post, Microsoft will not fix this problem soon. There is the technical possibility to do it ourselves, or we will have to wait for Visual Studio 2010 SP1? ...

Translate SQL to linq-to-sql (subquery)

How to I convert the following SQL statement into LinqToSQL? select t1.name, (select COUNT(*) from table2 where t2.f_id = t1.id) as cnt from table1 t1 My attempts seem to end up doing an inner join (and therefore giving wildly inaccurate results). Thanks ...

How can I transfer LINQ to SQL results to an external dll?

Before LINQ I would have my main application return the results of a SQL query into a dataSet. I would then transfer the dataset as a parameter to the external dll. Now I am bringing through a LINQ to SQL query that is returned as an IQueryable(Of vClientTable) object. I want to be able to transfer that set of vClientTable results to my ...

Linq to SQL - How to inner join tables from different Data Context?

I have two tables from two different Data Contexts. Although both tables are from the same database, two separate datacontexts exist. Error msg: "The query contains references to items defined on a different data context." How can I get around this? Any help is appreciated. Thanks. ...

Help to build LINQ query

I have SQL database as follows Now I want to filter the restaurant_detail table for the parameters: 1. cuisine 2. area Can you help me to build LINQ query? ...

LINQ to SQL: Lazy loading an association

How can I lazy load an association (EntitySet) in LINQ to SQL? You can't set Delay Loaded on Associations in the designer, and I couldn't find a DBML attribute for it either. I looked at DataLoadOptions to see if there was a way to lazy load them that way, but DataLoadOptions really just provides a way to mold the SQL that is generated f...

What does it mean that Linq To SQL is not scalable?

I've once heard from some developers that L2S is not scalable. I'm not sure that I fully understand what that means. I guess that it has something to do with the layers in your app (provided your app is a layered one). Can someone please shed some light on this subject? Thanks, Avi ...

Linq2sql naming convention

I have just started using Linq2sql, it generates all of the Classes after my tables which is awesome. my problem is that i have a lot of objects that have the same name as my tables. this is forcing my to fully namespace everything which i don’t really like as i think it makes my code look messy. Has anyone found an elegant way to get ...

Can't add System.Data.Linq or System.Web to project

I can't add System.Data.Linq or System.Web to project, each time I do I get a warning symbol yellow !, on the reference Any ideas why? I had it working all okay this morning ...

How can you coalesce a datetimeoffset in Linq to SQL?

I have a Linq query that orders by a datetimeoffest. The goal is to have the one that is NULL at the top, followed by most recent, 2nd recent, and so on. I started with this. orderby item.Date descending Doing it this way the NULLs go to the bottom. So I changed it to this. orderby (item.Date.HasValue ? item.Date.Value.Ticks : long.M...

Can multiple compiled linq queries be chained together?

I am trying to chain multiple compiled linq queries together. I have succeeded in chaining two queries together, but I cannot get a chain of three to work correctly. So here is a reduction of my code to recreate the issue. My two questions are: 'Why isn't this working?' and 'Is there a better way to keep the performance benefit of com...

Returning a single value with Linq to SQL

I'm learning Linq to SQL and I'm having trouble grasping it. I'm trying to simply return a single (boolean) value in C# with a Linq query. I want to see if the owner of a story would like an email notification sent when new comments are added. I would like the method that contains the Linq to SQL to return a boolean value. public bo...

Am I going about this the wrong way?

This is my first MVC/Linq to SQL Application. I'm using the out of the box SQL Membership with ASP.NET to track users through my system. As most of you know, the UserId is a guid, great. However, to link other user-created tables in the system, I decided to go with username instead of userid. The reason I did this was because: Use...

Returning a column from a linked table in LINQ to SQL

My problem is that I am trying to return a simple query that contains an object Story. The Story object has a UserId in the table which links to aspnet_users' UserId column. I have created a partial class for Story that adds the UserName property since it does not exist in the table itself. The following query gets all stories; howeve...

Automatically Calculated Properties in Linq 2 Sql Entities?

Let's say I have a table in my database called Orders that has the following columns: OrderId OrderDate CancelDate ShipDate LastActionDate I want LastActionDate to always be the latest date of OrderDate, CancelDate, and ShipDate. What's the best way to accomplish this? Is there a way to handle the OnChanged event of those three dates...