Category "linq"

C# LINQ single query to complete an incomplete model

I have a list of incomplete product models. Everyone is missing an owner and a price. Can these deficiencies be filled with a single query to context? Without t

displaying parent-child elements hierarchically in c#

I have a parent-child structure in my db and I want to list them hierarchically n a C# program: id text parentid 1 A NULL 2 B NULL 5 a1 1 6

How to use Automapper to project object to Dto in LINQ

I am working on .NET Core 6 along with EF Core. I want to convert Customer and Order object that I have inside LINQ select to CustomerDto and OrderDto using Pro

Can't find single property and navigate related data without IQueryable all properties

I have relational data properties on my objects that I would like to access: public class Person { public ICollection<Address> Addresses { get; private

IQueryable extension to group dynamicly by minutes ...and other

I wanted to create an IQueryable extension to allow other developers to group entities by minutely interval but also by custom group key result. My idea was to

LINQ Expression GroupBy Select First

I've got a question on LINQ Expression. I need to replicate the following lambda: var result = processRevisions OrderByDescending(pr => pr.CreatedAt) G

MAX and MIN on string array in c#

I have started to learn Linq recently. I came across a few inbuild methods like Min() and Max(). The working of these two methods is fine with int[]. But when i

LINQ query returns error "The expected type was 'System.Int32' but the actual value was null."

So this is the query: from c in Contents join cs in DepartmentSharings on c.ContentId equals cs.ContentId select c.PrivateCategoryId.Value When I run this I

Is there a more Functional way to aggregate a collection into set of Mongo Filters conjugated by OR?

We have a microservice which enables consumers (indirectly) to query a database, where we have our own logic to limit what consumers can do with the queries. Wh

Using LINQ to select the last record in .NET Framework

I need to query for the last record in a SQL database, utilizing LINQ. The way I am doing it now takes two steps. First, I get the ID value with a OrderByDesce

LINQ query with multiple LEFT JOIN

I have 1 main table and 3 tables for ordering the fields in the main table. I return all these tables as lists. The main table structure is like this: Color Ma

'Nullable object must have a value.' for List in LINQ c#

In database I have next model tblWorkItem with next field: public List<xWorkItemItemFailReason> WorkItemItemFailReasons { get; set; } When I am trying

Cast IQueryable<DomainModel> to IQueryable<EntityModel> for EntityFramework

I'm trying to convert an IQueryable to IQueryable to allow me to take advantage of the dynamic filtering offered by Linq in the EntityFramework context. I'm try

ef core angular - is there a way to get and display data from database in input box depends on another input box

First Input Box will ask the user to enter employee number Second Input Box (readOnly) - employee name will be display here automatic base on employee number pr

Dynamic where condition LINQ

I have a problem with my code. I don't know how I can insert in my selection all equals conditions of: codicielementipartizione.sezione == el[i].ToString() d

Linq most efficient top results

I'm wondered I have a table with IDs and a version and a remove field. I d like to return the the top 20 records grouped by ID and for ech ID take only the hig

How to Bulk Update records in Entity Framework?

I am trying to bulk update records using Entity Framework. I have tried Entity Framework.Extensions Update method. The Update method is able to bulk update for

Get ID of item selected in ComboBox

I have a ComboBox that gets filled with items from my database. I'm trying to get the ID of the item that is selected in the ComboBox, but nothing I've tried se

Groups the specified bookings based on their consecutive dates

var listForTestGroup = new List<Booking> { new Booking{Project="HR", Date= DateTime.Parse("01/02/2020") , Allocation= 10},

Check null value in a list using linq

I have a list List<OfferComparison> Comparison. I want to check if all the items have Value == null in an if condition. How can I do it with linq? publ