Questions tagged [linq]
Language Integrated Query (LINQ) is a Microsoft .NET Framework component that adds native data querying capabilities to .NET languages. Please consider using more detailed tags when appropriate, for example [linq-to-sql], [linq-to-entities] / [entity-framework], or [plinq]
86,699
questions
0
votes
3
answers
79
views
Sequence contains no elements in LINQ
In the code shown here, I am getting an error in LINQ:
Sequence contains no elements
When the reason column contains data, it is throwing this exception. Please suggest how to handle this exception.
...
0
votes
3
answers
58
views
Entity Framework C# join with one column only from second table
I have a join in Entity Framework connecting the Order and the OrderItem tables. All orders will have multiple order items. I'm trying to return all the orders, but only the orderItemStatus column ...
-2
votes
0
answers
29
views
Npgsql.PostgresException: '42703: column c.UserId1 does not exist [closed]
var list = _user.FindAll(
filter,
NoTracking: true,
hideDeleted: true,
take: data.Length,
page: data.Page,
orderBy: data.OrderString);
Error: Npgsql.PostgresException: '42703: ...
-1
votes
0
answers
53
views
Linq query for same table parentId
This is my table structure:
enter image description here
Now I want to result like this:
enter image description here
I wrote a SQL query shown here, and it returns results as expected, but I want it ...
0
votes
1
answer
30
views
The cast to value type 'System.Int32' failed because the materialized value is null LinQ
I do have below query,
(from p in _dbContext.MyTable
where batchIds.Contains(p.BatchId)
select new ParticipantToRespond
{
ParticipantId = p.ParticipantId,
TeamId = (p.TeamId ??...
1
vote
1
answer
49
views
How to delete the rows of datatable1 having different ID while compare with the datatable2
Given the first data table having master data and the second table having the needed data IDs, I need to delete the rows from the first table which are not present in the 2nd table. I am trying to use ...
-1
votes
0
answers
72
views
when converting the code from csv to xml, the text does not transfer from the file
When running the code, a terminal is launched in which all the text from my file is shown, but then when opening the file values is not there. What could be wrong.
About my code :
I try to convert CSV ...
0
votes
0
answers
28
views
Use some kind of helper function In EF Select query to make subquery [duplicate]
I have several tables that handles different kinds of translations for my entities and those tables to linked via relations to other entities.
I use subquery to directly access translations tables ...
0
votes
1
answer
49
views
How to group text to lines if there is small difference in Y position
Using PdfPig to read text from order PDF as described in Get Text Line By Line From PDF using C# answer
static void GetWordsInReadingOrder(UglyToad.PdfPig.Content.Page page, StringBuilder builder)
...
-1
votes
1
answer
61
views
LINQ query where clause in list
I am trying to limit the data returned via a repository using the where clause based on a list of values.
I have a PurchaseOrders entity where I want to return all purchase orders that have an ...
0
votes
3
answers
78
views
Selecting 2 Elements from XML
I am having a lot of trouble translating examples I am finding into use with XML.
Starting with this (a very cut down version of the whole XML file)
<?xml version="1.0" encoding="UTF-...
0
votes
2
answers
55
views
LINQ - Get key-value pairs for dictionary with lists
Let's say I have:
Dictionary<string, List<string>> test = new()
{
{ "animal", ["cat", "dog"] },
{ "fruit", ["banana", "apple&...
0
votes
0
answers
78
views
Linq query DateOnly fields returning results on comparing dates
I have this linq query request as:
var test = (...
where ...
&& test.SL.Any(line =>
line.ServiceCode == serviceCode
...
0
votes
2
answers
45
views
How to use Enumerable.Aggregate without getting CS0411 error
There are two DTO records:
public record struct DateHour(int Hour, double? Value);
private record struct HourSnapshot(uint TotalSeconds, double? Value);
I have another method which works with enum. I ...
3
votes
1
answer
71
views
Remove In Nested Loops (Remove Inside Foreach) [closed]
These are my entities:
public class Permissions
{
public string PermissionName { get; set; }
public List<Controllers> controllers { get; set; }
}
public class Controllers
{
public ...