I often get in a position when I need to know why my LINQ doesnt work as intended...
I use object collections and extensions.
I dont want spend more than couple of minutes on it. LINQ supposed to make developer's life easier not harder.
I hoped VS 2010 will have it fixed but I now use RC and it still doesnt let me type LINQ and check ...
Hi,
I am trying a LINQ to Object query on 2 collections
Customer.Orders
Branches.Pending.Orders (Collection within a collection)
I want to output each branch which is yet to deliver any order of the customer.
var match = from order in customer.Orders
join branch in Branches
on order equals branch.Pending.Orders
selec...
I have a list of objects. Each object has an integer quantity and a DateTime variable which contains a month and year value. I'd like to traverse the list and pad the list by adding missing months (with quantity 0) so that all consecutive months are represented in the list. What would be the best way to accomplish this?
Example:
Origina...
When writing a method chain for LINQ, I can do the Where statements one of two ways:
var blackOldCats = cats.Where(cat => cat.Age > 7 && cat.Colour == "noir" )
Or
var blackOldCats = cats.Where(cat => cat.Age > 7).Where(cat => cat.Colour == "noir" )
Are there any benefits of one over the other?
Don't worry too much about the datat...
Is it somehow possible to use the 'With' keyword on an existing object?
I would like to do the following using LINQ to objects and can't seem to find a way:
From m as Product in Me _
Select m With {.Match = m.Name.IndexOf(query)} _
Where m.Name.IndexOf(query) > 0
...
I have an XML structure that is 4 deep:
<?xml version="1.0" encoding="utf-8"?>
<EmailRuleList xmlns:xsd="EmailRules.xsd">
<TargetPST name="Tech Communities">
<Parse emailAsList="true" useJustDomain="false" fromAddress="false" toAddress="true">
<EmailRule address="@aspadvice.com" folder="Lists, ASP" saveAttachments="false" />...
I'm a bit surprised to find the results of the following code, where I simply want to remove all 3s from a sequence of ints:
var sequence = new [] { 1, 1, 2, 3 };
var result = sequence.SkipWhile(i => i == 3); // Oh noes! Returns { 1, 1, 2, 3 }
Why isn't 3 skipped?
My next thought was, OK, the Except operator will do the trick:
var s...
Hello,
I have pretty simple case which I started solving using foreach(), but then I thought I could do It using Linq
Basically I have IList that contains PaymentTransaction objects and there are 2 properties Dealer and Amount
I want to GroupBy() by Dealer and Sum() bv amount.
I tried to accomplish this using following code, but unfo...
This should be and easy one for the LINQ gurus out there.
I'm doing a complex Query using UNIONS and CONTAINSTABLE in my database to return ranked results to my application.
I'm getting duplicates in my returned data. This is expected. I'm using CONTAINSTABLE and CONTAINS to get all the results I need. CONTAINSTABLE is ranked by SQL a...
Hi.
We have issues within an application using a state machine. The application is implemented as a windows service and is iteration based (it "foreaches" itself through everything) and there are myriads of instances being processed by the state machine.
As I'm reading the MEAP version of Jon Skeets book "C# in Depth, 2nd ed", I'm won...
I have 2 instances of a class that implements the IEnumerable interface. I would like to create a new object and combine both of them into one. I understand I can use the for..each to do this.
Is there a linq/lambda expression way of doing this?
EDIT
public class Messages : IEnumerable, IEnumerable<Message>
{
private List<Message> ...
I have following object structure, deseralized from XML (WS):
<ns2:Category>
<ns2:CategoryId>800003</ns2:CategoryId>
<ns2:CategoryName>Name1</ns2:CategoryName>
<ns2:Categories>
<ns2:Category>
<ns2:CategoryId>800008</ns2:CategoryId>
<ns2:CategoryName>Name2</ns2:CategoryName>
<ns2:Categories>
<ns2:Categ...
I got a list that contains al the status items of each order.
The problem that i have is that i need to remove all the items of which the status -> logdate combination is not the highest.
e.g
var inputs = new List<StatusItem>();
//note that the 3th id is simply a modifier that adds that amount of secs
//to the c...
My career started as a hard-core functional-paradigm developer (LISP), and now I'm a hard-core .net/C# developer. Of course I'm enamored with LINQ. However, I also believe in (1) using the right tool for the job and (2) preserving the KISS principle: of the 60+ engineers I work with, perhaps only 20% have hours of LINQ / functional par...
I want to do a search for Music instruments which has its informations Name, Category and Origin as I asked in my post.
But now I want to sort/group the result by similarity/equality to the keyword such as.
If I have the list
{ Drum, Grand Piano, Guitar, Guitarrón, Harp, Piano} << sorted by name
and if I queried "p" the result should ...
I have a linq to objects query in a recursive loop and afraid when the objects approach more then 1000 and a have more then 100 users on the site -- my website will break. so is it possible to compile a linq to objects query.
The linq query does nothing more then find the direct children of a node.
...
I have an IList<MyList>. I'd like with LINQ keep the same list (same number of record) but I'd like reduce or/and rename some record. At the end I'd like to have IList<MyNewList>.
Update (Marc Gravell request)
We have tools to generate interface/object from Oracle stored procedure. My problem is, for some stored procedure, a lot of fiel...
I am trying to figure out how to do a series of queries to get the updates, deletes and inserts segregated into their own calls. I have 2 tables, one in each of 2 databases. One is a Read Only feeds database and the other is the T-SQL R/W Production source. There are a few key columns in common between the two.
What I am doing to set...
I'm not sure about clarity of the STAR word.
I'm implementing a search method using linq-to-object in c#.
And I want to do a search with * (star) operator like most of search apps or web can do.
e.g.
If I typed "p*", results should be everything starting with "p".
And it should work for prefix star, suffix star or star in the middle.
...
I've written the following Linq query:
IQueryable<ISOCountry> entries =
(from e in competitorRepository.Competitors
join c in countries on e.countryID equals c.isoCountryCode
where !e.Deleted
orderby c.isoCountryCode
select new ISOCountry() { isoCountryCode = e.countryID, Name = c.Name }
).Distinct();
The objective is...