Questions tagged [iqueryable]
.NET Framework Interface, providing functionality to evaluate queries against a specific data source wherein the type of the data is not specified.
1,440
questions
-1
votes
0
answers
24
views
How to convert IQueryable to GraphQL request?
I ran into a problem that I need to convert an IQueryable query, which is intended to be executed by the context. I came across only one library that solves the problem I need
But unfortunately it ...
-1
votes
0
answers
49
views
Proper way to handle NULL's with IQueryable<>
I have been trying to research best practices for handling NULL's, specifically using IQueryable when dealing with result sets from something like SQL Server using Dapper.
Take this for example:
...
-1
votes
1
answer
66
views
C# List.AsQueryable() returns System.Collections.Generic.List instead of IQueryable
I have a list of objects List<Student> that I want return as an IQueryable<Student>.
When I try to use .AsQueryable() on the list to convert it to IQueryable<Student> I got a System....
-1
votes
1
answer
22
views
Entity framework - Include an IQuaryable parameter
I read EF 5 introduced filtered includes.
This allows me to write something like this :
db
.MyCollection
.Include(mc =>
mc
.MySubCollection
.Where(msc => /* Some condition *...
0
votes
1
answer
63
views
.Net 6 Api Generic query sorting based on columnName type and order Asc Desc
I'm trying to gain some experience with .net 6 apis and I have designed a simple app in which the user can sort the data based on a specific column like name or created.
But now I also want to sort ...
0
votes
1
answer
37
views
Building GroupBy Expression Tree - IEnumerable parameter not defined error
I want to build an expression for IQueryable GroupBy. While at the moment I'm just simplifying the problem to try and get it working, the eventual final implementation will involve the creation of ...
1
vote
0
answers
15
views
Linq Expression Could Not Be Translated - DistinctBy Breaking Linq [duplicate]
Whenever I run this I get the above error. I am on .NET Core 6 and EF Core.
For some reason I only get the error when the DistinctBy clause is in there.
var notifications = _context.Notifications....
1
vote
0
answers
52
views
IQueryable difference between .NET 6 and 7
TL;DR: Disable Nullable on entities which are not manually configured using IEntityTypeConfiguration when upgrading.
I am currently in the process of upgrading our ASP.Net Core app to .NET 7. In ...
1
vote
2
answers
79
views
System.Exception : The provider for the source 'IQueryable' doesn't implement 'IAsyncQueryProvider'.- xunit and moq
I am working with xunit and moq.
I am trying to test FindAsyncTestAsync method return something (not null) using xUnit and Moq.
I have instantiated all the required mock repository instances using ...
0
votes
2
answers
67
views
Add Where clause to IQueryable<T> in function?
Why Where clause is not applied to IQueryable in the AddWhereToQuery function ?
It should be reference type and I cannot see why this code should not work as I expect.
[Route("/testing")]
...
0
votes
0
answers
39
views
How to filter data using IQueryable into a NHibernate DynamicJsonType Mapping
I'm saving a list of Json into a varchar on my data base
[
{
"Id":37,
"Name":"John",
"Departament":{
"Name":"...
0
votes
0
answers
26
views
DbSet only .Remove or .RemoveRange not working
I am trying to write a unit test for removing items from my dbset using the code below
var entitySet = Context.Set<TEntity>();
var entitiesToRemove = await entitySet.Where(request....
0
votes
0
answers
33
views
Intercept IQueryable Functions
I'm looking for a way to add some SQL Hints to all queries generated using .Count() in Entity Framework (EF 6).
So far i'v used DbCommandInterceptor to intercept all EF queries going through the ...
0
votes
0
answers
41
views
Linq Cascade Select with object generation in ef core
I have an api that has the following model keep in my that this's just an exemple to get the whole idea of my problem
namespace Models{
public class A
{
public int Id{get;set;}
...
0
votes
1
answer
130
views
No overload for method 'ProjectTo' takes 0 arguments
Error
Severity Code Description Project File Line Suppression State
Error CS1501 No overload for method 'ProjectTo' takes 0 arguments
C#
public static async Task<...
0
votes
1
answer
52
views
Property is not supported in LINQ-to-entities
I'm having a problem and I don't know how to solve it. I already watched millions of posts like this but doesn't help me.
I have this:
public interface IInterface
{
int Order { get; set; }
}
...
0
votes
2
answers
79
views
How to filter with Contains a vlaue object type in DDD repository?
I developed a project with the DDD method to manage holidays. I have 2 value objects with the names of HolidayTitle and HolidayDate.
Now I want to filter with Contains in the Query Repository but I ...
2
votes
0
answers
77
views
how to remove a condition from an expression IQueryable object in C#
I have an IQueryable object sth like;
IQueryable<People> query = DemoData.Where(x => true);
query = query.Where(p=> p.Nation == Nation); // query indicates people from a Nation now.
/*
....
0
votes
0
answers
33
views
EF Core non-existant column in query, how to rectify?
working my way through an EF core project I have inherited and am quite new when it comes to LINQ/EF core.
I'll cut this back to simplify things, and will demonstrate my problem with 4 basic tables.
...
0
votes
1
answer
73
views
C# Build query OR condition
I have a test method which I'd like to return a query which should have OR condition based on input.
Let's say I input 3 statuses [New, IsProcessing, Done] and I want the query to return Payments ...
0
votes
2
answers
44
views
Returning a list inside Linq query from left outer join
I'm new with Linq and hoping for some clarity on a particular query.
I have two tables (simplified for demonstration):
Table: Customer
CustomerId | Name
1 | John Smith
2 | Peter ...
1
vote
2
answers
42
views
Given an expression to be consumed by the "Where" method of an IQueryable, a nested "Any" method will accept a "Func<>" only if it's defined inline
Keep in mind that the inner Any method accepts a Func<MyChildEntity, bool> argument, not a Expression<Func<MyChildEntity, bool>>.
I think I'm aware of the difference between the 2 (...
1
vote
1
answer
47
views
Effects of IEnumerable and IQueryable on Relational Database and Non-Relational Database
I have started to learn Linq recently, So I came across IQueryable and IEnumerable. I have understood the difference and where to use what. But I have a small doubt will IEnumerable and IQueryable ...
0
votes
1
answer
238
views
Creating a group by parameter for the get method in a generic repository for entity framework
I am using the repository pattern with Entity Framework as described in this article: repository pattern with Entity Framework
In the part where the GenericRepository is described (Generic Repository) ...
0
votes
3
answers
129
views
Get a Sum of integers from an IQueryable
We use a SQL database in our ASP.Net Core solution that stores things and can also store zero to multiple item types for each thing. We also store a quantity for each item type stored. I need to be ...
0
votes
0
answers
45
views
c# Automapper ProjectTo DTO with count property
i have a question about automapper ProjectTo method, i have this DTO:
public class GetUsersResponse
{
public GetUsersResponse()
{
Users = new List<UserLite>();
}
public ...
0
votes
0
answers
52
views
Is there any method or way that I can get a value of an attribute of an object from a list of dynamics object's fields?
I need to get that single date which is underlined in red in the image, and store it into a variable, so I can create a conditional and use it as a param.
Through front end it comes dynamically ...
1
vote
1
answer
46
views
Retrieve IQueryable Result in Public Methods
Is it a valid architeture to declare public methods that retrieve IQueryable results like below :
public IQueryable GetData()
0
votes
1
answer
127
views
EF Core 6: How to use ILazyLoader (it doesn't get injected)
I am trying to use ILazyLoader in my EF Core 6 application.
public class IDM_Account
{
[Key]
[StringLength(80)]
public string account_id { get; set; } = string.Empty;
...
2
votes
2
answers
127
views
Linq Count() for IQueryable vs Linq Count() for IEnumerable
I am confused to understand the difference between Linq's Count() for IQueryable and Linq's Count() for IEnumerable.
I have the following method which has to return the same result of the counts, but ...
0
votes
0
answers
108
views
How i can localize enums with EF Core IQueryable projection?
I have asp net Web Api. In get all method I use EF Core IQueryable to retrieve data from DB. Then use project to for map Domain class to response class. Then send this queryable in LoadAsync method ...
0
votes
0
answers
57
views
How to count results from untyped IQueryable on the DB
In my code, I am getting back a value of type IQueryable - yes, the untyped, non-generic version. I am getting this IQueryable object from OData, so I neither know (at compile time) what the query ...
0
votes
1
answer
50
views
LastOrDefault() not supported on IQueryable {document}{}.LastOrDefault()is not supported
IQueryable<Patients> patients = db.Patients;
patients = patients.Where(x => x.Status.LastOrDefault().Status != Status.Imported);
On the 1st line I have a IQueryable data. (1,000+ data)...
0
votes
1
answer
302
views
Pagination with Take and Skip in .NET Core returns incorrect records when I use IQueryable
I have an IQueryable query.
Before applying pagination, I've been using this code:
query = pageSize != -1 ?
query.Skip(pageNumber * pageSize).Take(pageSize) :
query;
...
2
votes
0
answers
122
views
IEnumerable<ulong>.Max() and IQueryable<ulong>.Max() returns different result
I am new to Linq and trying to query an entity to get the max() value.
The pdmDocDrawingNumbers are 9999999, 524244222235, 1 and some others.
Only maxvalue0 has the correct value 524244222235.
...
0
votes
0
answers
83
views
OData AddODataQueryFilter with ActionResult
It is possible to use AddODataQueryFilter with endpoint which return ActionResult?
I have:
public class ODataQueryOptionsAttribute : EnableQueryAttribute
{
private const int _pageSizeDefault = 5;
...
0
votes
1
answer
241
views
In ASP.NET Core 6, is an IQueryable returned by a controller action enumerated asynchronously?
My question is similar to Making a Web API controller returning a IQueryable list asynchronous from 2013, and related to Should I call ToListAsync() when make a query. I want to focus specifically on ...
0
votes
0
answers
64
views
.Net Core .Count() does not work with IQueryable with Distinct() filter
Creating an IQueryable with .Distinct() If you try to apply query.Count() like for a paginator solution is not working but yes without .Distinct().
When I am using
var totalItems = query.Count();
...
1
vote
1
answer
416
views
generic repository doesn't let me add methods
I'm building an ASP.NET Core web application. The controller use a generic repository within methods like "Get, GetById, Post, Update ecc.". When i use these methods in the controller and I ...
0
votes
2
answers
232
views
How can I make a IQueryable of Generic Type in LINQ C#?
I have a method that takes an Id with name PcId on basis of that I am trying to retrieve data from different tables , how can I make a generic IQueryable ?
IQueryable<T> ...
1
vote
1
answer
129
views
C# IQueryable Contains with Multiple OR - Operator || can't be applied to operands of type 'bool'
I'm trying to have search functionality to my existing IQueryable object.
Here's my sample class:
public class Fruit {
public string Name {get;set;}
public string Origin {get;set;}
public ...
0
votes
1
answer
1k
views
EF LINQ Query throws a System.ArgumentNullException: Value cannot be null exception
I'm getting a weird exception at var result = flow.Disciplines (line 44). What's the issue there? What value is null? How do I solve it?
System.ArgumentNullException: Value cannot be null. (Parameter '...
0
votes
0
answers
234
views
'System.InvalidOperationException' occurs when trying to combine predicates for an expression tree query
I am trying to dynamically build the query using an expression tree and here is a simple demo code for the problem I am running into. Thanks so much for your help in advance.
Expression<Func<...
0
votes
1
answer
429
views
.NET & Entity Framework : query database by using IQueryable
I have a method which takes an IQueryable<TEntity> where all my filters have been applied and now I want to query the database by using this IQueryable
The IQueryable i defined like:
IQueryable&...
1
vote
1
answer
127
views
How to join two IQueryable queries together? [duplicate]
I want to join two queries into one, how can I do this?
For example:
Query #1:
query = query.Where(q => q.Currency == filter.Currency)
Query #2:
query = query.Where(n => n.FirstName == filter....
0
votes
1
answer
39
views
How to convert IQueryable<IList<AnimeTitle>> to IQueryable<AnimeTitle>
I need to get a collection by id, it has IList<AnimeTitle> AnimeTitles, which I need to convert to IQueryable<AnimeTitle> and project into BriefTitleVW to end up with IQueryable<...
4
votes
1
answer
421
views
How to filter IQueryable for null navigation property
Say I have 2 simple models (below), where 'User' contains a navigation property to 'UserDetail' (one-to-one relationship):
Database
CREATE TABLE [dbo].[UserDetail]
(
[UserId] [int] NOT NULL ...
0
votes
0
answers
84
views
c# mvc - how do i catch serialization errors that happen after endpoint execution?
i'm using a .NET 6 service. I have controllers marked with [ApiController] and a standard JSON serialization for every response data.
also i have a global exception handler registered that converts ...
0
votes
1
answer
62
views
Using a func parameter returns IEnumerable instead of IQueryable
I've minimised my issue to this:
I have a DbContext with a DbSet<PageBlock> and I get an IQueryable with a simple LINQ "Where" like so:
IQueryable<PageBlock> result = _context....
0
votes
1
answer
110
views
How to use Query to add value in IQueryable?
I want to add a value in IQueryable get from another IQueryable here is my code
var queryReturnRequest = query.Include(x => x.Assignment)
.ThenInclude(x => x.Asset).Select(x =>...