linq

DisconnectedContext was detected in LINQ To ActiveDirecory

Hi, I'm using LinqToActiveDirectory from codeplex and when I'm executing query using DirecotrySource I'm getting the following error: DisconnectedContext was detected Message: Context 0x3c5050' is disconnected. Releasing the interfaces from the current context (context 0x3c4f98).This may cause corruption or data loss. To avoid this pr...

How do you populate a parent child data structure from XML where generic List<> objects are in parent and child structures using one LINQ query?

I have an XML configuration file that contains a list of documents with field maps for each document. I want to use LINQ to XML to populate an internal data structure which represents the documents as a hierarchy of List<> structures. An attribute called Include determines whether the field should be included. Here is a sample of what ...

Linq Syntax issue

I'm having some issues with a bit of LINQ syntax and I believe I'm missing something very simple here. I've got a basic class defined as: public class ParseData { public int Offset { get; set; } public int Length { get; set; } public string AssociatedCode { get; set; } } I have a collection of these class items that will ...

Linq to Sql, derived to derived association

I dont know if its possibe. I have a base table with 2 derived tables. Mammal Mammal -> Boy Mammal -> Dog A want that Dog table has a foreign key(ownerBoyId) to Boy table, but linq designer dont permit, because Boy itself dont have a Id collumn, Id is inherited. How can I resolve this problem? Associate to Base class? ...

LINQ: Distinct values

Hi, I have the following item set from an XML: id category 5 1 5 3 5 4 5 3 5 3 I need a distinct list of these items: 5 1 5 3 5 4 How can I distinct for Category AND Id too in LINQ? ...

Let the SequenceEqual Work for the list....

I have a class named Country. It has the public members, 'CountryName' and 'States'. I have declared a list of Countries. Now I want to write a function which accepts a new 'Country' and decides if CountryList already has the 'Country'. I tried writing a function like bool CheckCountry(Country c) { return CountryList.Exists(p =...

What does full LINQ support mean?

Some O/RM tooling claim they have "Full LINQ support". What does that mean? Do they support all the LINQ operators ? ...

Why does 'Submissions.Where(s => (false && s.Status == Convert.ToInt16("")))' raise an FormatException?

I thought the query was quite trivial, but it's raising a FormatException ("Input string was not in a correct format") nonetheless: Submissions.Where(s => (false && s.Status == Convert.ToInt16(""))) (of course, in my code, another expression that evaluates to 'false' is located before '&&') So why is the part after '&&' evaluated, si...

How do I implement a dynamic 'where' clause in LINQ?

I want to have a dynamic where condition. In the following example: var opportunites = from opp in oppDC.Opportunities join org in oppDC.Organizations on opp.OrganizationID equals org.OrgnizationID where opp.Title.StartsWith(title) select new ...

Duplicate Rows when Data Binding with LINQ to Entities

I have problems binding both a telerik RadGrid and a plain vanilla ASP.NET GridView to the results of the following LINQ to entities query. In both cases the grids contain the correct number of rows, but the data from only the first handful of rows is duplicated in all the other rows. I'm directly assigning the return value from this c...

How to build an XDocument with a foreach and LINQ?

I can use XDocument to build the following file which works fine: XDocument xdoc = new XDocument ( new XDeclaration("1.0", "utf-8", null), new XElement(_pluralCamelNotation, new XElement(_singularCamelNotation, new XElement("id", "1"), new XElement("whenCreated", "2008-12-31") ), n...

Is there any way to use LINQ for MDX queries?

Anyone know if there are plans for LINQ to MDX . Does any way currently exist to use LINQ with MDX / CUBES ...

LINQ CompiledQuery.Compile and dynamic sorting?

This is a very short question and I fear the answer is short too. Is there any way of doing anything along the lines of Func<DataContext, string, bool, IEnumerable<X> fnMyQuery = CompiledQuery.Compile<DataContext, string, bool IList<X>( (db, sortColumn, sortDesc) => ( (!sortDesc)? db.OrderBy(x => DynamicRes...

Linq Join on Mutliple Properties

Are the below two queries functionally the same? The first one doesn't return any data, but the second works fine with same exact input. Can someone point out what's wrong in my first query? Dim LTest2 As IEnumerable = From e1 As QNCEntity In Shape.Entities _ Join e2 As QNCEntity In Shape.Entities _ ...

Do Compiled Queries Cache?

Much of my application uses complied queries to retrieve data. In these queries I'll often refer to the current user. I'm noticing that if a user, B, logs in after another user, A, then user B will see user A's informaiton. I have querries much like this all through out the application public static Func<DataContext, MyRecord> CurrentU...

Linq to XML - Weird where results

Hello everyone, I'm new to Linq and having some strange results when I try to perform a query using where. Example of the xml: <movies> <movie id="1"> <scenes> <scene id="1"> <sceneartistsnames> <sceneartistname>Artist A</sceneartistname> </sceneartistsnames> <...

Merging cross referenced XML-files

I'm co-developing a vehicle information system that reads and presents data from a communication bus. Signaling information on the bus is stored on some kind of database (from the dark ages i'd guess) from which it's only possible to get data out of by extracting a xml-snapshot. Since that wasn't bad enough, someone in upper management t...

How to use DateTime in WHERE clause (LINQ)?

How to add date is where clause. I am using following code. var opportunites = from opp in this.DataContext.Opportunities join org in this.DataContext.Organizations on opp.OrganizationID equals org.OrgnizationID select new ...

Conditional Multiple Fields Searching and Filtering in LINQ

Assuming that we have the following table: Person: PersonID, Name, Age, Gender And we are providing a search function that allows users to search the table according to the name and/or the age. The tricky part in writing the SQL ( or LINQ) query is that the users can choose to search for both field, or any one field, or no fi...

IMultipleResults LINQ DBML Classes Not Resolving

In my partial class which defines a function which returns the type of IMultipleResults to bring back multiple result shapes from a stored procedure using the classes defined in my *.dbml file, for some reason the [ResultType(typeof(MyType))] isn't working. The MyType is saying that it cannot be found. The function is in the .cs file o...