Fastest way to count number of uppercase characters in c#
Any thoughts on the efficiency of this? ... CommentText.ToCharArray().Where(c => c >= 'A' && c <= 'Z').Count() ...
Any thoughts on the efficiency of this? ... CommentText.ToCharArray().Where(c => c >= 'A' && c <= 'Z').Count() ...
I have two tables say A and B. A cols are GUID, someintVar, someMoreIntvar B col are GUID, someItemNO, SomeItemDesc Now for one GUID I will have only one row in Table A. But I can have multiple rows for the same GUID. Now I want to query the database based on GUID and select values in a class. This class will have a list that will hold ...
I have a list with tick objects including a pair of a double value and a timestamp. I want to separate the list into child-lists depending on a time interval (for example 15 minutes). One list only has the tick objects from: 8:00:00 - 8:14-59 usw usw C#-code: var result = from tick in listTicks group tick by tick.timestamp.Hour; Th...
I have this Linq to SQL query sequence that is basically returning a search on a table called PROJECTS. and I'm taking advantage of the deferred execution to slowly build it up. var query = from p in objDBContext.PROJECTs where (p.PROVIDER_ID == cwForm.productForm) select p; query = from p in query where p.SubmittedDate >= cwForm.beg...
I have a LINQ query which gives me a list with a number of child lists all with double values. I want to get a queryResult from this. How can I get the first, the last, the highest and the lowest double value? Should it be a new object and should the new return values be a list? ...
All of our current ASP.Net web apps access our IBM I Series using an ODBC connection and command object. Should I move to another way of accessing it? How do you current access your I Series when your ASP.Net app needs data from it? There has to be a better way. I recently saw this article about IBM supporting Linq to Entities with a sp...
I am trying to use the Extensibility Method Definitions from my datacontext.designer.cs file to do some validation. So I created a new file and added this code: public partial class LawEnforcementDataContext : System.Data.Linq.DataContext { partial void InsertCourse(Course instance) // this definition copied from generated file ...
I'm using parallel linq, and I'm trying to download many urls concurrently using essentily code like this: int threads = 10; Dictionary<string, string> results = urls.AsParallel( threads ).ToDictionary( url => url, url => GetPage( url ); Since downloading web pages is Network bound rather than CPU bound, using more threads than my num...
I'm in a situation where I am being informed from an outside source that a particular entity has been altered outside my current datacontext. I'm able to find the entity and call refresh like so MyDataContext.Refresh(RefreshMode.OverwriteCurrentValues, myEntity); and the properties which have been altered on the entity are updated corr...
I'm looking for the LINQ equivalent to the Sybase's LIST() or MySQL's group_concat() It'll convert: User Hobby -------------- Bob Football Bob Golf Bob Tennis Sue Sleeping Sue Drinking To: User Hobby -------------- Bob Football, Golf, Tennis Sue Sleeping, Drinking ...
I have found out (in a hard way) that a collection that is being enumerated cannot be modified within "Foreach" statement "Collection was modified; enumeration operation may not execute." Now, the solution I came up with is to create a dummy collection of the same size that contains a dictionary key and enumerate over it to modify ...
After disposing my datacontext, linq still holds data for other separate calls with new datacontext to those entities. Shouldnt this have been been cleared? ...
I have used the "select" keyword and extension method to return an IEnumerable<T> with LINQ, but I have a need to return a generic Dictionary<T1, T2> and can't figure it out. The example I learned this from used something in a form similar to the following: IEnumerable<T> coll = from x in y select new SomeClass{ prop1 = value1, p...
It's pretty common - especially as you try to make your code become more data-driven - to need to iterate over associated collections. For instance, I just finished writing a piece of code that looks like this: string[] entTypes = {"DOC", "CON", "BAL"}; string[] dateFields = {"DocDate", "ConUserDate", "BalDate"}; Debug.Assert(entTypes....
Here's the LINQ query I have, it gets the unique value for each selected column and stores them as a list in a dictionary. var serialTable = serialNoAdapter.GetData(); var distinctValue = (from row in serialTable select new { ...
Trying to get my head into Linq to Objects and for the life of me it escapes me...I want to get a list of all the products where the _name starts with J. Product prod; for (int i = 0; i < 10;i++ ) { prod = new Product(); prod._Name = "J" + i.ToString(); prod._Sur...
Why do I get the following error in the following code? I thought if I put custom objects in a generic List of its type then IEnumerable would be taken care of? What else do I need to do to this List to use LINQ on it? Cannot implicitly convert type 'System.Collections.Generic.IEnumerable<TestLinq23.Customer>' to 'TestLinq23.Cus...
i make a group by and get child lists... during query i create a new obj with var result3 = from tick in listTicks group tick by bla bla into g select new { Count = g.Count(), Key = g.Key, Items = g, Timestamp = g.First...
My entity has a property which is derived from other properties public class MyClass { public DateTime Deadline { get; set; } public Severity Severity { return (DateTime.Now - Deadline < new TimeSpan(5, 0, 0, 0)) ? Severity.High : Severity.Low; } } is there a way I can modify the following return repository.Q...
I am new to Linq world and currently exploring it. I am thinking about using it in my next project that involves database interaction. From whatever I have read, I think there are 2 different ways to interact with databases: Linq to SQL Linq to DataSet Now the product that I am to work on, cannot rely on the type of database. For ex...