"Nested foreach" vs "lambda/linq query" performance(LINQ-to-Objects)
In performance point of view what should you use "Nested foreach's" or "lambda/linq queries"? ...
In performance point of view what should you use "Nested foreach's" or "lambda/linq queries"? ...
If we abstract out the DataContext, then are L2S and L2O queries identical? I already have a working prototype which demonstrates this, but it is very simple and wonder if it will hold up to more advanced querying. Does anyone know? ...
I have the following objects: public class Agency { public int ID; public IEnumerable<BusinessUnit> BusinessUnits; } public class BusinessUnit { public int ID; public decimal AmountSpent; public IEnumerable<Client> Clients; } public class Client { public int ID; public decimal AmountSpent; } ...
I have the following objects. An IEnumerable<Agency> Agencies, which then contains BusinessUnits and BusinessUnits contain clients: public class Agency { public int ID; public IEnumerable<BusinessUnit> BusinessUnits; } public class BusinessUnit { public string Name; public int ID; public decimal Amoun...
I have an the following class I'm trying to create a list of with a bunch of data I have queried: public class Agency { public string AgencyName { get; set; } public int AgencyID { get; set; } public IEnumerable<AuditRule> rules { get; set; } } Where "AuditRule" is: public class AuditRule { public int AuditRuleID { ...
Using the C# compilers query comprehension features, you can write code like: var names = new string[] { "Dog", "Cat", "Giraffe", "Monkey", "Tortoise" }; var result = from animalName in names let nameLength = animalName.Length where nameLength > 3 orderby nameLength select animalName; In the query expression above,...
Hi there I'm a .NET guy originally, working in Java recently, and finding I'm really missing LINQ to Objects, specifically for performing filtering against collections. A few people here on Stack Overflow have answered the "LINQ for Java?" question with a single word : Quaere However, on the site it clearly states "Pre-Beta", an...
I wanted to run a LINQ query against a MatchCollection object but found this wasn't possible as it doesn't implement ICollection<T>, just ICollection. What is the best option for using LINQ with non-generic collections, both in terms of code conciseness but also performance and memory usage? (If interested, here is the non-LINQuified c...
Consider the following class hierarchy: public class Foo { public string Name { get; set; } public int Value { get; set; } } public class Bar { public string Name { get; set; } public IEnumerable<Foo> TheFoo { get; set; } } public class Host { public void Go() { IEnumerable<Bar> allBar = //Build up some large list //Get...
I have the following query I'm using (which mostly came from the help I received here): public IEnumerable<Entities.AuditAgency> GetAuditRuleAgencyRecords(IEnumerable<Entities.AuditRuleEnterprise> rules) { using (LinqModelDataContext db = new LinqModelDataContext()) { // Left-Outer Joins on Agency and...
I have some LINQ code that generates a list of strings, like this: var data = from a in someOtherList orderby a select FunctionThatReturnsString(a); How do I convert that list of strings into one big concatenated string? Let's say that data has these entries: "Some " "resulting " "data here." I should end up w...
I'm trying to stick some data into the app so I can then build a public string get + linq query to pull out just the bits I want when I need them. I'm just struggling to store it and then how I'd go about pulling it back out so I can query against it... public void CommonDatatoApp() { CDataResponse cCommonData = this.GatewayReferenc...
Greetings! I want to use LINQ to query a list of objects and sort them by an enumeration value, string value then union the rest of the list sorted in a similar fashion LINQ newbie here, so be gentle. //CTOR for my class MyClass(id, "Name Value Here", Enum.EnumValueHere); I create a list of these objects and want to variably sort th...
I have the following function + code to parse and query a webservice request then in theory store the results in the application (as it only needs to refresh once a day, which luckily is when the application refreshes). //tocommondata is a reference to the common stuff in the webservice var dCountries = toCommonData.PropertyCountries; /...
I currently have a list that contains the following CountryCode (string) CountryStr (string) RegionStr (string) RegionID (int) AreaStr (string) AreaID (int) This is a flattened set of linked data (so basically the results of a joined search that ive stored) The MVC route will only pass one string which I then need to m...
After much Google searching and code experimentation, I'm stumped on a complex C# LINQ-to-objects problem which in SQL would be easy to solve with a pair of ROW_NUMBER()...PARTITION BY functions and a subquery or two. Here's, in words, what I'm trying to do in code-- the underlying requirement is removing duplicate documents from a lis...
I currently have a LINQ query implemented as a method of my DataContext class. This method calculates the permissions a user has for a page within a Wiki/CMS. What I'd like to do is relocate this method to the Page and User LINQ data objects. However, when I move this query to the individual data objects it executes using LINQ to Obje...
I have sql as below SELECT Q.MaterialID AS MaterialID, Q.ProductID AS ProductID, QB.Quantity AS Quantity, Q.ParameterID AS ParameterID, SUM((Q.ParameterValue * Q.Quantity)/Q.TotalTonnes) AS ParameterValue FROM @Quality Q INNER JOIN @QuantityBreakdown QB ON ((Q.MaterialID = QB.MaterialID) OR (Q.MaterialID IS NULL AND QB.MaterialID...
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...
Linq is a very useful feature of C# 3.0 which has been out for a while now. Unfortunately, a number of the developers at the company I work for do not know much about Linq and how it can benefit them. As such, I've been given the opportunity to present an information session about Linq. What I'm trying to figure out is, what is the best...