1,357 questions
0
votes
1
answer
62
views
Improve performance of Moving Average calculation. IEnumerable vs List, foreach vs for, ElementAt,
I created a class to calculate a Exponential Moving Average:
public class ExponentialMovingAverage {
public Int32 Period { get; set; }
public ExponentialMovingAverage(Int32 period = 20) {
...
-2
votes
1
answer
62
views
Why won't it sort my ICollection correctly using the instance method OrderByDescending?
I have an ICollection<Plante> Jardin which I want to sort according to some property Plante.Taille:
private readonly ICollection<Plante> Jardin;
I use the instance method ...
0
votes
1
answer
1k
views
Return a single object from a list of C# objects checking for matching properties
I have a requirement to create an object 'factory' that works as follows:
Accepts a list of matching object types.
Compares each property value in the list to see if they match.
Returns a new single ...
0
votes
2
answers
654
views
LINQ for equivalent for-loop on multi-level nested collection, extracting index information
I have an instance variable _foo declared like so -
List< Dictionary<int, HashSet<int> > > _foo;
Yes, it is a messy data structure that is a List of Dictionaries whose key is an ...
0
votes
2
answers
663
views
LINQ to Object - How to implement WHERE clause `If at least one of the elements is` for sub-group
I have a type of non-ordered records:
public class Row {
public string Client { get; set; }
public string Account { get; set; }
public string Status { get; set; }
}
and its instantiation ...
1
vote
2
answers
70
views
How to LINQ DataTable with group by and order by to deduplicate data
I have the following datatable
Col1
Col2
Col3
A
B
1
A
B
2
A
C
1
The Col1 and Col2 is the unique key so the first and the second row is duplicated.
The Col3 differ so I would like to have an option to ...
0
votes
1
answer
566
views
Optimize the slow query in-memory List using LINQ for retrieving data
I have a LINQ query that I am having trouble optimizing. It takes about 6 seconds to run.
IList<Note> notes;
data = client.Configuration.Data.OfType<UWData>()
.Where(s => s....
0
votes
1
answer
59
views
Pick line with the highest value of birth in every shop-country section
have been trying for several hours to resolve the problem but i cant sos
here is the tables im working with on pastebin
var result = E
.Join(A, a => a.ID, aa => aa.ID,
...
-1
votes
1
answer
715
views
trying to use linq aggregate function
I have below query where i am using the where clause with select and getting the result (list of librarySourceRowInputs) and would like to use the aggregate instead of (where and select).
In this ...
0
votes
3
answers
314
views
LINQ : prevent creating of new object, ( appending to a list attribute if object exists )
( I am a beginner with C# )
I wants to create a list of Person class using 2 lists, List of Users and List of Post here is how the class structure looks. Problem : while Creating Object using LINQ, i ...
0
votes
3
answers
1k
views
How can I convert 'System.Collection.Generic.List<String>' into 'System.Windows.Documents.List'?
I have a table of doctors in my database. So I'm trying to get the list of the firstName of the doctors in my database.
In the ViewModel class I'm using this code to get it
public List DoctorsList ()
...
1
vote
2
answers
1k
views
How to modify IEnumerable with LINQ to avoid foreach loop? [duplicate]
Can the following be done in LINQ as a one-liner, without using a for-loop?
IEnumerable<MyObj> MyList = EF.GetList(etc);
foreach (var row in MyList)
{
row.uploadedAt = MyUtils....
0
votes
2
answers
473
views
How to populate my class object with linq to EF?
my class,
public class User
{
public string Username
{
get;
set;
}
public string Password
{
get;
set;
...
0
votes
1
answer
168
views
How do i check string to see if all characters are integers, that it is 8 characters in length and throw an argument for each?
Class student and the main are just for reference.. In the try catch block there are two separate s1.SNum = "string" that should each throw a separate argument but both throw the same one every time ...
0
votes
3
answers
1k
views
How to select list of objects inside another list of objects
public class Account
{
public List<Memo1> Memos { get; set; }
}
public class Memo1
{
public string Memo { get; set; }
public DateTime AddDate { get; set; }
public string UserID {...
-3
votes
3
answers
113
views
Linq to objects is 20 times slower than plain C#. Is there a way to speed it up?
If I need just the maximum [or the 3 biggest items] of an array, and I do it with myArray.OrderBy(...).First() [or myArray.OrderBy(...).Take(3)], it is 20 times slower than calling myArray.Max(). Is ...
3
votes
0
answers
39
views
Is there a "correct" way between these two statements that filter and return a boolean using LINQ to Objects? [duplicate]
I'm trying to determine if there is a correct way to first filter a collection and then determine if any items in the collections pass the filter condition. The two (basic) statements I'm trying to ...
0
votes
2
answers
62
views
how can i get a collection from an item in another collection that is also a collection
I would need:
a list(of employee) that contains all the employees contained in all companies. (e1,e2... e9)
the employee how has the oldest DischargeDate higher than 1/1/2018
I have solved it in this ...
3
votes
1
answer
3k
views
Use LINQ to concatenate multiple rows list with same value into single row
Group the repetitive value in the object list using Linq query.
I have the following data as table called "SudentAssessment" with these data.
AssessmentId Username SITSupervisor ...
0
votes
0
answers
83
views
Query objects for one to many relationship in LINQ
I have a problem which seems to be quite similar to
Query objects for one to many relationship in LINQ
I've been trying to solve my problem referring the above but somehow I've been failing for a ...
-3
votes
3
answers
1k
views
LINQ Performance Optimization
I have the following LINQ query that I want to optimize. Our system is heavily dependent on this, so even slight optimization will help over all. Any ideas are welcome, not sure where to even start..
...
-2
votes
1
answer
278
views
Linq - filter list
I am building a simple search tool in vb.net windows forms application with sql server database,
The user will enter a unique id and will see the results which shows the status.
Object Class:
...
1
vote
1
answer
801
views
LINQ extension method to create Where query
I am trying to create an extension method that will be usable for both LINQ-to-Object and LINQ-to-Entities for creating a functioning Where query. More will go into it eventually but to start I am ...
-1
votes
2
answers
474
views
Filtering Object values in C#
i've got a C# web Api receiving the following object :
"cars": {
"bmw": true,
"benz": false,
"kia": true,
"hyundai": false,
"madza": false,
"ford": ...
0
votes
3
answers
161
views
Sort List<T> on a property in a related List<T>
Say we have two List<T>. The first is a list of sales totals:
class SalesTotals
{
public Guid EmpID { get; set; }
public string EmpName { get; set; }
public decimal? TotalSales { ...