I have two IEnumerable
IEnumerable<MyObject> allowedObjects = MyService.GetAllowedObjects();
IEnumerable<MyOBject> preferedObjects = MyService.GetPreferedObjects();
We can safely assume that preferedObjects will always be a subset of allowedObjects.
I want to create an IDictionary<MyObject, bool>. Objects where the key is the set of M...
Hi,
I want to add some rows to a database using Linq to SQL, but I want to make a "custom check" before adding the rows to know if I must add, replace or ignore the incomming rows.
I'd like to keep the trafic between the client and the DB server as low as possible and minimize the number of queries.
To do this, I want to fetch as little...
I'm using Enumerable.ToDictionary to create a Dictionary off of a linq call:
return (from term in dataContext.Terms
where term.Name.StartsWith(text)
select term).ToDictionary(t => t.TermID, t => t.Name);
Will that call fetch the entirety of each term, or will it only retrieve the TermID and the Name fields from my data...
I want to group items from a linq query under a header, so that for each header I have a list of objects that match the header title. I assumed the solution would be to use ToDictionary to convert the objects, but this allows only one object per "group" (or dictionary key). I assumed I could create the dictionary of type (String, List Of...
Scenario
Having already read a post on this on the same site, which didn't work, I'm feeling a bit stumped but I'm sure I've done this before.
I have a Dictionary.
I want to take the first 200 values from the Dictionary.
CODE
Dictionary<int,SomeObject> oldDict = new Dictionary<int,SomeObject>();
//oldDict gets populated somewhere...
I was following the answer to another question, and I got:
// itemCounter is a Dictionary<string, int>, and I only want to keep
// key/value pairs with the top maxAllowed values
if (itemCounter.Count > maxAllowed) {
IEnumerable<KeyValuePair<string, int>> sortedDict =
from entry in itemCounter orderby entry.Value descending s...
I have created a Dictionary class (MyDictionary for the example). I am currently trying to pass MyDictionary into a function, filter it into a new instance of MyDictionary and pass this new instance into another method.
When I am attempting to create the second instance from the filtered first instance of MyDictionary via Lambda Expres...
I am trying to build a dictionary from an enumerable, but I need an aggregator for all potentially duplicate keys. Using ToDictionary() directly was occasionally causing duplicate keys.
In this case, I have a bunch of time entries ({ DateTime Date, double Hours }), and if multiple time entries occur on the same day, I want the total ti...
I have a table with a structure like this:
Column1 AS INT,
Column2 AS INT,
Column3 AS INT,
Column4 AS DECIMAL
My LINQ query is this:
var query = from t in context.Table select t;
I want to convert/transform the query to this Dictionary object:
Dictionary<int, Dictionary<int, Dictionary<int, decimal>>>
using only the ToDictionary...