linq

Linq to NHibernate vs. ICriteria

I use LINQ a lot in general, especially LINQ-to-Objects, hence I'm rather fluent in LINQ. I was considering to use LINQ-to-NHibernate as the query language for my NHibernate project. When I wrote some tests, I noticed that LINQ-to-NHibernate doesn't make the same query as ICriteria. Since I'd prefer to use LINQ, I'd like to ask if anyon...

Comparison operators not supported for type 'System.String[]'

why this line: var category = _dataContext.Categories.Where<Category>(p => p.Keywords.Split(' ').Contains<string>(context.Request.QueryString["q"])).First(); throws an System.NotSupportedException: Comparison operators not supported for type 'System.String[]' And how can I fix it? Thanks. ...

Validate Linq2Sql before SubmitChanges()

Can anyone tell me if/how you can validate the changes in a data context in Linq2Sql before calling SubmitChanges(). The situation I have is that I create a context, perform multiple operations and add many inserts alongside other processing tasks and then rollback if the submit fails. What I'd prefer to do is make some kind of "Valida...

Linq: What is the difference between Select and Where

In linq there is the Select and Where methods. What should every developer know about these two methods (Example: when to use one over the other, any advantages over the other, etc) ...

How can I give alternative names to new objects created by LINQ?

How can I give specific names to the customers variable's properties, e.g.: PSEUDO-CODE: var customers = from c in Customers where c.Orders.Count > 15 orderby c.Orders.Count ascending select new { c.ContactName as Name, c.City, c.Orders.Count as NumberOfOrders }; ...

Why would a Database developer use LINQ

I am curious to know why should a Database person learn LINQ. How can it be useful. ...

Need lambda expression OrderBy with DateTime conversion

I am trying to create a lambda expression (Linq, C# 3.5) that can perform a OrderBy on a value that is of data type String but which actually contains a parse-able DateTime. For example, typical values may be "5/12/2009" , "1/14/2008", etc. The OrderBy clause below works correctly for ordering (as if string data), but I actually want ...

issue with submitChanges() inserting unwanted records in linq

I am using LINQ to insert records in the database. I create these records and keep track of them using a List. Based on some logic, I delete some of the records by deleting from the List. (I am using the same DataContext object). When I want to insert the records in the database, I do the corresponding linq table's InsertOnSubmit() fol...

LINQ Where() Single or Double Pipes / Ampersands

Anyone care to comment on whether we should be using "I" or "II" and "&" or "&&" in our LINQ Where() extensions / queries? Any difference with LINQ to SQL? The resulting expression tree is more than I can get my brain around on a Friday afternoon Thanks, static void Main(string[] args) { var numbers = new int[] { 1, 2, 3, 4, 5, 6, ...

When do LINQ-to-SQL queries execute?

I just want to confirm... LINQ-to-SQL queries never execute (hits the database) until it is enumerated, right? Does anyone know if this is the same for LINQ-to-Entities? Thanks! ...

nested xml with linq in repeater

Hi, I've got a xml file that looks like this and I'm trying to get all the location attributes in a table cell. I managed to get the title and description but somehow fail to get all the locations within events. Can someone help me out on this? Cheers Terry What I've come up so far is the following var qListCurrentMonth = (from fee...

LINQ to Entity Framwork: return sorted list of related rows

Table Category (c) has a 1:many relationship with Table Question: a Category can have many Questions but a Question belongs only to one category. The questions are also ranked in terms of difficulty. I would like a LINQ to EF query that would return all Categories with related Questions but the Questions should be sorted ascending ...

What is the Java equivalent for LINQ?

What is Java equivalent for LINQ? ...

Is LINQ (or linq) a niche tool, or is it on the path to becoming foundational?

After reading "What is the Java equivalent of LINQ?", I'd like to know, is (lowercase) language-integrated query - in other words the ability to use a concise syntax for performing queries over object collections or external stores - going to be the path of the future for most general purpose languages? Or is LINQ an interesting piece o...

What is after LINQ?

In the spirit of All about LINQ Current LINQ providers: LINQ to Objects. LINQ to SQL. LINQ to XML. LINQ to Entities. LINQ to WMI. LINQ to LDAP. LINQ to Internet. LINQ to Dataset. LINQ to nHibernate. So, what is after LINQ? Does there any data source LINQ not cable of querying it? [Edit] From Adam Robinson's answer: What sort of da...

What is LINQ to events a.k.a RX Framework?

What is LINQ to events a.k.a RX Framework aka the Reactive Extensions in .NET 4.0 (but also available as backported versions)? In other words, what is all the stuff in System.Reactive.dll for? ...

Why is FxCop raising the error "Types that own disposable fields should be disposable" on a class with no disposable fields?

I have a LINQ object with an additional method added to it. The class has no disposable properties or methods, but FxCop is raising the error "Types that own disposable fields should be disposable" and referencing that class. I've reduced the code this far and still receive the error: partial class WikiPage { public PagePermission...

Visual studio C# Linq bulk insert/update

Hi, I have recently developed a C# application using Linq. I am getting from an external database a list of profiles I need to process, some are new and some are already in the database, and need to be updated. What I do today is go over the profile list and check each profile if such exists I update otherwise I insert - this solution is...

How does LINQPad reference other classes, e.g. Books in the LINQ in Action samples

I'm using LINQPad to create LINQ queries in an application I'm bulding. I noticed that in the downloaded LINQ in Action samples, e.g. example 4.04, intellisense shows a class "Books" but I don't see any references or "using" statements in the LINQPad tool, here is the sample: List<Book> books = new List<Book>() { new Book { Title="LI...

How can I get the first element after an element with LINQ-to-XML?

With this code I can get the title out of the following XML file: var xml = XElement.Load (@"C:\\test\\smartForm-customersMain.xml"); string title = xml.Element("title").Value; But how do I make it more exact, e.g. "get the first element after the smartForm element, e.g. something like this: //PSEUDO-CODE: string title = xml.Element(...