linq-to-sql

Linq outer join with grouping in subquery

Hi, I need to convert the following correlated subquery in Linq to Sql. I am able to achieve the left outer join part. However, grouping in a subquery is where i am getting incorrect results. SELECT ae.Id,ae.Title ,(select COUNT(*) from [dbo].[AssociationEventRSVP] where RSVPStatus='Y' group by AssociationEventId, RSVPStatus havi...

Linq2Sql or Nhibernate for MVC.NET project

I am going to make a smaller website in MVC.NET, mostly to learn how to work with the MVC.NET framework. I can't decide if I should use NHibernate or Linq2Sql as my Data Access Layer. Linq2Sql would much easier and faster to setup, but it doesn't have the capabilities as NHibernate (2 layer caching etc.). So would it be wiser to use mor...

Linq to SQL Sum()

select sum(Sales) from WeeklyProductSale. how i can write this query in linq and what this query will return to me. thankas in advance. ...

Linq to sql/C# - multiple where search off key/value pairs

I'm new to Linq to Sql and am trying to do the following in C#. I have a table that's a key/value store (that also has an fk to a user). I want to do a search off the key names and values as an or. On the front end, I allow them to add "filters" that are key names, then they can search for a value. So they can search N items, where N...

SQL to LINQ query, return objects AND count nicely bundled together..

An employee can have multiple vehicles.. And a company can have multiple employees.. My mission is to get the Companies that therefore have the most vehicles.. I have the LINQ query working perfectly (phew)! It returns (via select new {}).. CompanyID EmployeeVehicleCount Fantastic! BUT.. I want to be able to pull out "Company" ob...

Linq to SQL intellisense has no knowledge of tables within the datacontext object.

I can successfully connect to the database with my datacontext object. I am able to read and write to the database successfully, however I can't use the same syntax that others appear to be using. For example, when I want data from a table, I have to do something like this: db = new UserDataDataContext(WebConfigurationManager.Connecti...

How to force Linq 2 SQL to use EXEC instead of EXEC SP_EXECUTESQL

We are executing stored procedures using L2S and during trace analysis we noticed that LINQ uses SP_EXECUTESQL instead of EXEC. I do understand that there are advantages of using SP_EXECUTESQL, but we are in the process of troubleshooting a mysterious DB issue and I was wondering if it's possible to force LINQ use EXEC instead of EXEC ...

Search implementation using ASP.NET MVC 2 / jQuery (Performance & Security concerns)

Happy Halloween everyone, hope it was a fun night! I've just implemented an AJAX search functionality on my first ever ASP.NET MVC project, and I just want to get your feedback on security and performance. The project is going to be a simple Forum, with roughly 40 topics and 1000-3000 total posts. Let me show you some code. In my Top...

Binding datagridview to a multiple table linq-to-sql query

I'm binding the results of a linq-to-sql query to a datagridview. This works fine if I'm just selecting from a single database table. However, if it's a join query where I'm selecting fields from both tables, then because the select is going into an anonymous type, the results are readonly. Hence my datagridview is also readonly. I want ...