-
Notifications
You must be signed in to change notification settings - Fork 3.2k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
EFCore 3.1 + CosmosDb can't translate any() on owned object #20441
Comments
Can you provide us what would be expected SQL server side to get the same results? |
If this were on SQL server instead of Cosmos, you could use this to get the orders that have OrderDetails select * from Orders Or Select * from Orders |
We are talking about Cosmos translation. Cosmos does not run all the SQL, SqlServer can run. |
It's surely possible to get a list of objects that has more than one owned object. Right? Seems pretty basic. Mongo can do it. |
Surely you can use mongo then. |
Is that your passive aggressive way of saying no, it doesn't support that? |
It is pretty clear fact that EF Core 3.1 does not support that hence you got an exception. If we want to make it working in future version of EF Core then we need a way to represent that in SQL. I don't think discussing about other databases and their capabilities answer that question. |
It's also pretty clear what I'm trying to accomplish. Instead of passive aggressive, you could have offered a workaround, or a simple, I'm sorry, we don't support querying objects that are owned. The mongodb comment was quite valid considering that you can talk mongo protocol to CosmosDb. I would be using it, but that would mean losing EFCore. |
There is no work-around else I would have offered you one. While CosmosDb internally use same engine for Azure SQL and mongodb, the protocol to talk to each API is different. Just because CosmosDb mongodb API can do something does not necessarily mean there is SQL equivalent. |
Ok, here's working SQL |
Hello everyone, I've got the same issue. public class ArticleEntity
{
public Guid Id { get; set; }
[Required, StringLength(1000)]
public string Title { get; set; }
public ICollection<ArticleTagEntity> Tags { get; set; }
}
public class ArticleTagEntity
{
public Guid TagId { get; set; }
} and this is my DB context, public DbSet<ArticleEntity> Articles { get; set; }
protected override void OnModelCreating(ModelBuilder modelBuilder)
{
modelBuilder.Entity<ArticleEntity>().ToContainer("Articles").Property(p => p.Id).ValueGeneratedOnAdd();
modelBuilder.Entity<ArticleEntity>().OwnsMany<ArticleTagEntity>(p=> p.Tags);
} we are using the above classes and we use Odata URL for retrieving, see example below: https://localhost:44326/odata/articles?$filter=Tags/any(c: c/TagId eq 9c60ad92-bd94-4e78-9ece-3a583e7a1004) this creates the error below:
Also when we do this in LINQ code like below it gives the same error:
This is a test situation, I think this should be supported. Thank you in advance, |
@ajcvickers I too am having a similar problem with Entity Framework using CosmosDB provider..
When I execute this simple query...
I get the same unsupported exception based upon this generated output...
This seems like the most basic of requirements for the EF Cosmos provider. Is there a work-around? Thanks in advance. |
@jkears If you can express it in SQL that Cosmos understands, then you can try using FromSqlRaw. |
I am seeing similar issue but not even on owned entity in my case, directly at root entity level ( |
Closes dotnet#16926 Closes dotnet#20441 Closes dotnet#25700 Closes dotnet#25701 Closes dotnet#33032
Closes dotnet#16926 Closes dotnet#20441 Closes dotnet#25700 Closes dotnet#25701 Closes dotnet#33032
Closes dotnet#16926 Closes dotnet#20441 Closes dotnet#29497 Closes dotnet#25700 Closes dotnet#25701 Closes dotnet#33032
Closes dotnet#16926 Closes dotnet#20441 Closes dotnet#29497 Closes dotnet#25700 Closes dotnet#25701 Closes dotnet#33032
I have a query that seems to be pretty basic. I'm using Core3.1 on top of CosmosDb. I simply want to query a list of orders that have order details, but I'm getting this error:
.Where(b => EF.Property>(b, "OrderDetails") .Any())' could not be translated. Either rewrite the query in a form that can be translated or switch to client evaluation.
Client evaluation isn't an option
Consider this contrived example:
I do this in my sleep with SQL. What gives?
The text was updated successfully, but these errors were encountered: