linq

LINQ to SQL Query Syntax

I have several tables that center around an organization table that simply holds a unique ID value. Each Organization can then be at a particular location and have a particular name. The tricky part is that the organizations support location and name changes with a specified effective date of each change. For this example I have 4 releva...

How C# Compiler choose SelectMany when translating LINQ expression?

There are 4 overloaded signatures for Enumerable.SelectMany. To make it simple, we ignore the two signatures with int argument. So we have 2 signatures for SelectMany: public static IEnumerable<TResult> SelectMany<TSource, TResult>( this IEnumerable<TSource> source, Func<TSource, IEnumerable<TResult>> selector ) public static I...

What's a good "mobile" .NET database that supports LINQ?

I'm in the process of refactoring an application and I've decided to use a mobile/embedded database. I've been reading about SQL Server Compact Edition, but I was wondering if any of you knew of any other databases that could be used and don't have huge download sizes, as my current application is about ~2MB (installer). SQLite would be...

How to covert c# code into vb.net (Linq)?

var result = from с in dal.context.Funds select new { Name = c.CODE Price = c.Price }; ...

In statement for LINQ to objects

Is there an equivalent of a SQL IN statement in LINQ to objects? ...

How to write this nested Linq To Xml query

Hi I am writing an app for a medical study they will type in the gender, the age, and some other values which will be calculated to a ResultValue now I have an XML file which holds some information about the result in combination of Age, Gender and the ResultValues and I would like to print out the description of the TestResult (in c...

Better way to cleanly handle nested XML with LINQ

I'm working with XML that was designed by somebody who got paid by the level of nesting. The different xml files always looks something like this: <Car> <Color> <Paint> <AnotherUselessTag> <SomeSemanticBs> <TheImportantData> With LINQ its easy to get what I want: ( not exactly...

LINQ to XML updates - how does it handle multiple concurrent readers/writers?

I have an old system that uses XML for it's data storage. I'm going to be using the data for another mini-project and wanted to use LINQ to XML for querying/updating the data; but there's 2 scenarios that I'm not sure whether I need to handle myself or not: 1- If I have something similar to the following code, and 2 people happen to hit...

Running out of DB connections using LINQ to SQL

In developing a relatively simple web service, that takes the data provided by a post and records it in a database table, we're getting this error: Exception caught: The remote server returned an error: (500) Internal Server Er or. Stack trace: at System.Net.HttpWebRequest.GetResponse() on some servers, but no others. The ones that ...

Where to draw the line - is it possible to love LINQ too much?

I recently found LINQ and love it. I find lots of occasions where use of it is so much more expressive than the longhand version but a colleague passed a comment about me abusing this technology which now has me second guessing myself. It is my perspective that if a technology works efficiently and the code is elegant then why not use ...

LINQ to SQL: Mapping a subset of an association

During our initial development we haven't worried about scaling concerns, just getting the bare bones of the system working as a cohesive whole. We are now looking at refining screens where the quantity of records will become too large to be displayed. For example, we have page for displaying the details of a Parent which currently invo...

Refresh problems with databinding between Listview and ComboBox

Hello, I am wrestling with a binding problem in WPF/Silverlight. I have a Listview witch is filled by a DataContext form an EF linq query. In the same usercontrol are textboxes. When changing their values, the listview gets refresht and the data is changed in de db bij .SaveChanges. The problem is that if I use a combobox the data is sa...

How to query (LINQ) multiple table association link ?

Hi there I have tables association such as (CaseClient is a bridge table): Cases has many CaseClients Client has many CaseClients ClientType has many CaseClient The easiest way just use the view in database but I heard that with linq you can join this somehow? Or should I just created view in the database and linq query agains that...

Zipcode to city/state look-up XML file?

Trying to find an XML file I can use in lieu of a look-up database table until we get our web hosting switched over to the right DB. Can anyone refer me to an XML file with elements whose children have zipcodes, states, and cities? E.g.: <zip code="98117"> <state>WA</state> <city>Seattle</state> </zip> Or <entry> <zip>98...

Correct use of Lambda query.

Consider the following code: private static void WriteProcesses(StreamWriter sw, DateTime d) { sw.WriteLine("List of processes @ " + d.ToString()); Process[] localAll = Process.GetProcesses().Where(o => o.ProcessName.ToLower() != "svchost"); if(localAll.Length > 0) { ...

C# Excluding related values from a list (LINQ)

Is there an exact opposite action to "join" in linQ to SQL? I want to display just the results that do not fulfill the inner join constraint from a query. I wanna do it just in one query. Here's an example of it's use (http://img165.imageshack.us/img165/4940/liststj3.jpg). ...

How can I use a List<> as the condition for my where clause with Linq?

So I've been banging my head against the proverbial wall for a few hours and I thought I'd see if anybody else has solved this problem before... I have a List<string> of values that I want to use as filters on a search. In the olden days I would build a string of WHERE field = 'a' OR field = 'b' OR field = 'C' into the query. But with L...

Nested LINQ query using Contains with a bigint

This is the SQL I want (ClearinghouseKey is a bigint): select * from ConsOutput O where O.ClearinghouseKey IN ( select distinct P.clearinghouseKey from Project P Inner join LandUseInProject L on L.ClearinghouseKey = P.ClearinghouseKey where P.ProjectLocationKey IN ('L101', 'L102', 'L103') and L.LandUseKey IN ('U000', 'U001', '...

How do I use xml to linq when I don't have the Google Reader Atom Schema?

I am working on a small widget for BlogEngine.Net. My widget is going to take a person's shared items atom feed and print the title, website url, date, and atom url. To complete this task, I have begun to use Linq and XML. Here is the problem. The atom feed Google Reader uses is located in the source element, which has an attribute ...

What would be a good way to add "friendly" column names to a LINQ to SQL model?

I have a LINQ to SQL model setup - however in my app there are certain places where I want "friendly" column names for example: "NameFirst" to be "First Name" "AgencyName" to be "Agency" Just looking for suggestions on where the best place/technique to create these mappings would be - without changing the model. These mappings won't ne...