linq

How do I select 50 to 100 rows from Azure Table using the StorageClient?

I need to select several rows within a single partition of Azure Tables for later update. Since they all have the same PartitionKey, how do I structure my query to select multiple RowKeys? I'm interested in what the raw (on the wire) query should look like, and if possible the Linq query as well. I attempted this on my own and started...

EF 4 LINQ Expression load items based on related entity

Here is the expression x => x.stf_Category.CategoryID == categoryId x refers to an Product Entity that contains a Category. I am trying to load all Products that match given categoryId. In the db the Product table contains a Foreign Key reference to Category (via CategoryId). Question: I think I am doing it wrong. Is there somethi...

linq Can't perform Create, Update, or Delete operations on 'Table(req)' because it has no primary key.

how i can add the rows in table when the table not have primary key. ...

Help creating an instance of a class using Linq and XML

I am trying to create an instance of a class using Linq and XML. I am getting the following error in my code and do not know how to fix it. My code editor is telling me the "select" in the following code is the culprit. I am very new to Linq so any help is appreciated. Cannot implicitly convert type 'System.Collections.Generic.IEnume...

ASP.NET DropDownList bound to data but allows for nulls?

I'm using LINQ to SQL and want to be able to select a parent or no parent. Let's say I have a People table with PersonId, Name and ParentId columns. In ASP I want to enter the name, select a parent and click 'Add' to create a new Person record, but I also want to be able to leave the ParentId null. Don't ask why, this is just a simpli...

Linq to mess up order of an array?

Update: False alarm! The source of the error was elsewhere. (See at the end of the question.) Is it possible that either Linq or foreach can mess up the order of an array? One of my testers reported to have experienced that the order of a list of items he fed in as input didn't match the order of the final list that was saved in the da...

Alternative to BLINQ, CLINQ, Obtics

Hi guys, I am addicted to Bindable LINQ but it is no longer updated. And the version of Silverlight is poor. What do you use in your projects? Some people use Rx Framework to replace this ? Best regards, Vincent ...

LINQ to XML - how do I obtain index

I have an array of Car objects and using the following piece of code I create an XML Document from these objects. I have set up a counter variable i to be able to index the Car elements in the document. Is there a different way of obtaining the index of the currently processed element? int i = 0; XDocument doc = ...

Linq Query If Field Is In An Array?

The code below is incorrect but the idea here is that I want to grab values from "SqlTable" where the value for "Field" is inside of "Array[]". var Result = from a in SqlTable where a.Field is in Array[] select a; ...

LINQ and Visual Studio 2010 Memory Usage

I have a created a single LINQ query that creates a main group and then two nested groups. Within the last nest there is also a simple OrderBy. The issue I am running into is while writing the query or trying to edit it the visual studio memory consumption sky rockets to ~500MB and is eating 50% of my CPU, which makes visual studio unr...

Like condition in LINQ....

I am relatively new to LINQ and don't know how to do a Like condition. I have an IEnumerable list of myObject and want to do something like myObject.Description like 'Help%'. How can I accomplish this? Thanks ...

In condition using LINQ

OK, another LINQ question. How do I do an "IN" condition using LINQ. I have an IEnumerable list of myObject and want to do something like myObject.Description in('Help', 'Admin', 'Docs'). How can I accomplish this? Thanks ...

Any way to make this LINQ faster?

I have a LINQ expression that's slowing down my application. I'm drawing a control, but to do this, I need to know the max width of the text that will appear in my column. The way I'm doing that is this: return Items.Max(w => TextRenderer.MeasureText((w.RenatlUnit == null)? "" : w.RenatlUnit.UnitNumber, this.Font).Width) + 2; Howeve...

LINQtoXML nested collections and values?

I have some XML: <Request> <EmailAddress>string</EmailAddress> <Item> <name>FirstName</name> <value>John</value> </Item> <Item> <name>LastName</name> <value>Doe</value> </Item> </Request> My object: public class TheObject{ publ...

Comparing a possibly empty string in C#

Hi all, I'm trying to compare a string field from a LINQ query on a database using: e.Comment.equals("Working From Home") on the WHERE clause. However, sometimes the Comment field could be empty which currently causes an Object reference not set to an instance of an object exception. Is there any way I can check if the Comment isn...

How to get all Types using LINQ in Asp.net mvc

Hello Friends, I have this code viewModel.Messages = repository.GetAllMessages().OrderBy(x => x.MessageText); with this I am getting 75 messges and i am displaying all the Messages in the Grid with two columns MessageText and MessageType But I need to write a Linq Query to get all my Distinct MessageTypes from Messages? Can any ...

Efficient conversion of an array into a two-dimensional one using LINQ

I want to do the below in a performant way in C#, preferably using LINQ. Array[Length] to Array[Length/Row][Row] where Row and Length are variables. ...

Is it possible to have auto filters in Linq to SQL ?

Hi ! I am working on a system that the client decided to use status for the records. One of them is X for excluded. What I want to know is if it is possible to run linq queries that adds something like where status != 'X' Automatically to not show "excluded" records. Thanks ! ...

How do I select a List from something like new Dictionary(int, List<Customer>);

Dictionary<int, List<Customer>> dictionary = new Dictionary<int, List<Customer>>(); I want to query based on the key and get a List back. Not sure how to structure the LINQ query for that. Desired Output: A List<Customer> for a particular key in the Dictionary. ...

Why can Linq operations be faster than a normal loop?

A friend and I were a bit perplexed during a programming discussion today. As an example we created a fictive problem of having a List<int> of n random integers (typically 1.000.000), and wanted to create a function that returned the set of all integers that there were more than one of. Pretty straightforward stuff. We created one linq s...