linq

LINQ expression until to break a string

Using LINQ I'm looking to break down the following path string[], however I'd like to break it up to the point of the Binn folder. Is there a WHERE UNTIL operator in LINQ? c:\Program Files\Microsoft SQL Server\MSSQL10.SQLEXPRESS\MSSQL\Binn\sqlservr.exe What I'd like todo var words = from word in thepath where UNTIL thepath == "Binn"...

Creating a Linq->HQL provider

Hi all, I have a client application that connects to a server. The server uses hibernate for persistence and querying so it has a set of annotated hibernate objects for persistence. The client sends HQL queries to the server and gets responses back. The client has an auto-generated set of objects that match the server hibernate objec...

GridView ObjectDataSource LINQ Paging and Sorting using multiple table query.

I am trying to create a pageing and sorting object data source that before execution returns all results, then sorts on these results before filtering and then using the take and skip methods with the aim of retrieving just a subset of results from the database (saving on database traffic). this is based on the following article: http:/...

LINQ to SQL Single Table Inhertiance

I am using LINQ to SQL with single table inheritance for an audit log. There is a field/property called Type that i am using as the dicriminator and i have created a base type and a single inherited type (there will be more later if i can actually get this to work). So that i don't have to write a different method to insert each diffe...

LINQ Query with dynamic where clause based on search criteria that is NOT part of the returned object

I have an AlumniRecords table with 60+ columns. I created an AlumniSearchResults class that only contains the handful of fields I need for display in a table of search results. This is an MVC2 app so I want to keep the objects clean (in other words, I don't want to pass the 60+ field object to my view). I am trying to build my AlumniS...

Necessary files to deploy for website using linq

I'm new @ linq and can't find anywhere where it mentions if the dbml or other files are necessary to deploy with a website. ...

How to apply LINQ to ObjectResult<int?> when using EF 4.0?

Suppose I have a function call from EF like: var result = context.myFunction(); the result type is ObjectResult<int?>. Then I want to use linq to get the single value. How to write the linq? ...

ASP.Net Entity Framework Repository & Linq

My scenario: This is an ASP.NET 4.0 web app programmed via C# I implement a repository pattern. My repositorys all share the same ObjectContext, which is stored in httpContext.Items. Each repository creates a new ObjectSet of type E. Heres some code from my repository: public class Repository<E> : IRepository<E>, IDisposable where...

How to deal with large result sets with Linq to Entities?

I have a fairly complex linq to entities query that I display on a website. It uses paging so I never pull down more than 50 records at a time for display. But I also want to give the user the option to export the full results to Excel or some other file format. My concern is that there could potentially be a large # of records all bei...

LINQ and paging with a DataTable - can't get Skip working?

Ok so this might be a dumb question, but I can't seem to figure it out. I thought I'd try out LINQ against a DataTable. I got my query working and now I'm trying to implement some simple paging. DataTable dataTable = null; dataTable = GetAllDataTables(); var query = from r in dataTable.AsEnumerable() orderby r.Field<string...

Selecting distinct records in a declarative linq data source?

How can I select distinct records when using a declarative data source? <asp:LinqDataSource ID="dsColors" runat="server" ContextTypeName="Context" OrderBy="Id, Name" Select='new (Id, String.Concat(Id + ": " + Name) as ColorName)' TableName="Colors"> </asp:LinqDataSource> ...

Utility of List<T>.Sort() versus List<T>.OrderBy() for a member of a custom container class

I've found myself running back through some old 3.5 framework legacy code, and found some points where there are a whole bunch of lists and dictionaries that must be updated in a synchronized fashion. I've determined that I can make this process infinitely easier to both utilize and understand by converging these into custom container cl...

How can I use linq to select the columns of a jagged array

How can I use linq in C# to select the columns of a jagged array of ints, I select the rows as follows. int[][] values; .... var rows = from row in values select row; Thank you for the help. ...

Total runtime checks and NHibernate

Would a increasing value of performace counter total runtime checks indicate a performance issue, when it seems to be coming from Session.Linq of NHibernate? This has been measured in a asp.net environment. Regards ...

.Net Linq - Doing a operation on the subset

I need to have the following : (name1 + "a") + (name2 + "a") + ... Dim separator() As String = {"|"} myString.Split(separator, StringSplitOptions.None).SomeLinq(...) I don't know what to add at the end to add an "a" to each element... ...

Linq join two dictionaries using a common key

Hello, I am trying to join two Dictionary collections together based on a common lookup value. var idList = new Dictionary<int, int>(); idList.Add(1, 1); idList.Add(3, 3); idList.Add(5, 5); var lookupList = new Dictionary<int, int>(); lookupList.Add(1, 1000); lookupList.Add(2, 10...

LINQ. Grouping by days. How to do this easily?

I can't seem to find any god reference on this. I have alot of data in SQL with dates. So I wanted to make a line chart to show this data over time. If I want to show it over a perioud of days then I need to group by days.. But the LOGDATE is the full date.. not the DAY.. So I have this below.. but LINQ doesnt know what 'DayOfYear' pro...

LINQ How to force query to materialize?

Say I have simple LINQ extenstion: var filtered = data.Where(i => i.Count > 0); I know that this will not evaluated unless I start to use filtered i.e. foreach(DataItem i in filtered) ... However I need to create cloned version of data and release data as soon as possible. data can be changed in other thread so I want to get immed...

Precompile Lambda Expression Tree conversions as constants?

It is fairly common to take an Expression tree, and convert it to some other form, such as a string representation (for example this question and this question, and I suspect Linq2Sql does something similar). In many cases, perhaps even most cases, the Expression tree conversion will always be the same, i.e. if I have a function public...

Handling auto-incrementing IDENTITY SQL Server fields with LINQ to SQL in C#

I'm building an ASP.NET MVC site that uses LINQ to SQL to connect to SQL Server, where I have a table that has an IDENTITY bigint primary key column that represents an ID. In one of my code methods, I need to create an object of that table to get its ID, which I will place into another object based on another table (FK-to-PK relationshi...