Comments (7)
From @SimonTouchtech on November 20, 2015 16:6
Seems to be the same as dotnet/efcore#3732?
from efcore.pg.
@chbach, as @SimonTouchtech suggests this seems to be the same as dotnet/efcore#3732, which is a core EF7 and not an Npgsql problem. Can you please confirm and close this issue if so?
from efcore.pg.
From @chbach on December 6, 2015 19:26
In fact, I didn't observe this behaviour with SQLite, it only appeared after I switched from SQLite to PostgreSQL. Apart from the wrong query generation, there are still relations missing in the final collection, so something with Include() in combination with Skip() and Take() and the population of relations must be wrong.
from efcore.pg.
Hi, i have this error in 1.0.1.
Then i use include - Order by not working
If i have select before order - it working
var entities = this.dbSet.Include(x => x.User).Select(x => new GameRewardLogsGridBackendModel { Id = x.Id, DateReward = x.DateReward, Place = x.Place, Reward = x.Reward, RewardId = x.RewardId, GroupingId = x.GroupingId, Description = x.Description, UserId = x.UserId, UserName = x.User.Name, DispositionId = x.DispositionId }).OrderByDescending(u => u.DateReward) .Skip(skip) .Take(take);
and not working (ordering by Include(x => x.User))
var entities = this.dbSet.Include(x => x.User).OrderByDescending(u => u.DateReward) .Skip(skip) .Take(take).Select(x => new GameRewardLogsGridBackendModel { Id = x.Id, DateReward = x.DateReward, Place = x.Place, Reward = x.Reward, RewardId = x.RewardId, GroupingId = x.GroupingId, Description = x.Description, UserId = x.UserId, UserName = x.User.Name, DispositionId = x.DispositionId });
and not working to
var entities = this.dbSet.OrderByDescending(u => u.DateReward).Include(x => x.User) .Skip(skip) .Take(take).Select(x => new GameRewardLogsGridBackendModel { Id = x.Id, DateReward = x.DateReward, Place = x.Place, Reward = x.Reward, RewardId = x.RewardId, GroupingId = x.GroupingId, Description = x.Description, UserId = x.UserId, UserName = x.User.Name, DispositionId = x.DispositionId });
from efcore.pg.
Hi,
I have the same problem. I reported it on EF github but I wonder if it's not related the provider.
dotnet/efcore#6492
this code :
context.Produits.Skip(skip).Take(take).Include(c => c.ProduitCategories).ThenInclude(c => c.Categorie).ThenInclude(c => c.Famille).ToList()
seems to produced :
SELECT "p0"."Produit_ProduitId", "p0"."Categorie_CategorieId", "c"."CategorieId", "c"."Famille_FamilleId", "c"."OrdreAffichage", "c"."Titre", "f"."FamilleId", "f"."OrdreAffichage", "f"."Titre"
FROM "ProduitCategorie" AS "p0"
INNER JOIN "Categories" AS "c" ON "p0"."Categorie_CategorieId" = "c"."CategorieId"
INNER JOIN "Familles" AS "f" ON "c"."Famille_FamilleId" = "f"."FamilleId"
WHERE EXISTS (
SELECT 1
FROM "Produits" AS "p"
WHERE "p0"."Produit_ProduitId" = "p"."ProduitId"
LIMIT 10 OFFSET 10)
ORDER BY "p0"."Produit_ProduitId"
Now with a rapid analyze of this sql code, I understand why it doesn't work...
The SELECT in the EXISTS clause only return 1 row... when an OFFSET occured (more than 0) obviously the result is false.
So, I'm not a expert on SQL performance, but a query like this do the job :
SELECT "p0"."Produit_ProduitId", "p0"."Categorie_CategorieId", "c"."CategorieId", "c"."Famille_FamilleId", "c"."OrdreAffichage", "c"."Titre", "f"."FamilleId", "f"."OrdreAffichage", "f"."Titre"
FROM "ProduitCategorie" AS "p0"
INNER JOIN "Categories" AS "c" ON "p0"."Categorie_CategorieId" = "c"."CategorieId"
INNER JOIN "Familles" AS "f" ON "c"."Famille_FamilleId" = "f"."FamilleId"
WHERE EXISTS (
SELECT 1
FROM (SELECT "p1"."ProduitId" FROM "Produits" as "p1" LIMIT 10 OFFSET 10) AS "p"
WHERE "p0"."Produit_ProduitId" = "p"."ProduitId"
)
ORDER BY "p0"."Produit_ProduitId"
Is this problem is related to EF core or to the PGSQL provider ?
from efcore.pg.
I don't have time to dive into this right now, but there's little chance this is an Npgsql provider issue - it's most likely an EFCore issue. One easy way to help out would be to simply test this on SqlClient with LocalDB - it's really trivial to get a small model together and run this query (see the EFCore getting started). This will at least tell us exactly where the problem is.
from efcore.pg.
Closing for each, likely to have been fixed in EF Core a long time ago.
from efcore.pg.
Related Issues (20)
- Support value conversion with generated properties HOT 4
- Running simultaneous queries on different DbContext instances leads to `NpgsqlOperationInProgressException` HOT 3
- Map User Defined Function return table value with parameter timestamp without time zone HOT 3
- Cannot rename system column "xmin" HOT 3
- Reverse engineering for view does not preserve nullability of columns HOT 4
- ISSUE: A PostgreSQL type with the oid '0' was not found in the current database info
- SQL translation error when using LEFT JOIN in `Where` HOT 6
- Upgrading INpgsqlArrayConverter to PrimitiveCollection
- EF.Functions support for json_array_length HOT 2
- Npgsql.PostgresException (0x80004005): 42883: function st_contains(deployment.geometry, deployment.geometry) does not exist HOT 4
- ISet<EnumType>.Contains() does not translate in EF Core 8 HOT 1
- EF.Functions.JsonContains() occurs issue after upgrade to .net 8
- Querying a DateTimeOffset in a jsonb as JsonDocument fails with InvalidCastException
- Translation from Contains to strpos leads to extremely slow queries HOT 1
- GroupBy with joined table produces sub optimal query
- Unable to write data to the transport connection: Operation canceled. HOT 7
- Date/time column type mapping to DateTimeOffset / DateOnly / TimeOnly HOT 7
- When upgrading to 8.0.2, using LINQ's [all] and [contains] will cause translation failure. HOT 4
- Is it possible to have a proxy property for json/jsonb field for LINQ-query purposes? HOT 1
- Undocumented breaking change of stringValue.Contains(value) in v8
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from efcore.pg.