Questions tagged [LINQ] (77)

1
answer

Grouping and Summing values from a CSV file using Linq C#?

I'm new and trying to figure things out, there is a CSV file which contains data in one column,example: 03.03.2020,100 04.03.2020,150 09.04.2020,130 10.04.2020,150 Note: DateTime Value You need to group the data for 1 month (sum of them) and get the average value for the month (for example, in the 4-5 month of sales, that...
agustin.Ledn asked April 8th 20 at 09:24
1
answer

LINQ Where clause not working when filtering DateTIme, what's wrong?

if (dto.birthDate != "") { DateTime birthDate = Convert.ToDateTime(dto.birthDate); BirthDate1 DateTime = Convert.ToDateTime(dto.birthDate).AddDays(1).AddTicks(-1); items = items.Where(e => e.BirthDate >= birthDate && e.BirthDate <= birthDate1); } After items reset
kay.Eichmann asked April 7th 20 at 16:29
1
answer

How to get duplicate mark?

For example renege letter e. Can linq do that?
Albertha.Marks asked April 7th 20 at 10:43
1
answer

Could you tell me the basic rules of work with migrations in asp.net?

Good day! Deal with migrations in Entity Framework .net. Give an example of metanite what I'm doing: https://metanit.com/sharp/entityframework/3.12.php In all of these manuals are marked the basic things that issues do not arise. But if we dig even this resource comments, it becomes clear that getting out is not the obvious...
Tatyana.Yundt asked April 2nd 20 at 16:42
1
answer

LINQ How to decompose the list into three possible equal list?

The source data is a list of arbitrary length L123 list (1, 5, 7, 3, 2, 9, 1) The goal is to spread as uniformly as possible into three lists L1, L2, L3 Algorithm Sort descending L123 L123 list (9 ,7, 5, 3, 2, 1, 1) Looking for the sum of L1, L2, L3 and any minimum list add first element L123, and so on. Summary L1(9); L2(7...
callie.Ryan asked March 29th 20 at 21:43
1
answer

How to collect a variable of type List(List(T)) a variable of type List(T) contains all the elements using LINQ?

In the method, the need arose out of a list of lists to create a list with all elements from the list of parents.Example FromList>List<List<int>> list = new list<List<int>>(); for (int i = 0; i < 10; i++) { list.Add(new List<int>()); for (int j = 0; j < 10; j++) { list[i].Add(i + j ...
alanis_Hirthe asked March 29th 20 at 19:51
2
answers

DefaultIfEmpty &lt; TSource &gt; why not supported?

DataContext db = new DataContext(GetConnection()); Table<Car> carTable = db.GetTable<Car>(); var customers = db.GetTable<Customer>(); Table<Customer> customerTable = db.GetTable<Customer>(); var allCustomerByNumber = from customer in customerTable join car in carTable on customer.Number...
Susan26 asked March 27th 20 at 13:39
1
answer

How to speed up a query in the controller?

There's a controller [HttpGet("StockOnHand")] public IActionResult GetStockOnHand() { var storeList = context.Stores .Where(x => x.GeomarketName.StartsWith("RCA")) .Where(x => x.SubSubSegmentName.StartsWith("WS")) .Where(x => x.SegmentId == "WSV"); var tempList = storeList.Select(x => x.StoreId); var St...
petra86 asked March 24th 20 at 14:50
0
answer

How to fix linq to sql?

Work with ado.net. I have created generic repository:public class Repository<T> : IRepository<T> where T : class, IEntity { protected Table<T> DataTable; public Repository(DataContext context) { DataTable = context.GetTable<T>(); } public void Delete(T entity) { DataTable.Attach(entity); } pub...
Catherine.Franecki asked March 24th 20 at 14:22
1
answer

List c#, you should find the same elements, how to do it?

do cheat, I have a model sheet modules, and there is a sheet which is constantly updated I need to learn not matching items
Marie_Mueller asked March 24th 20 at 14:09