[EF-72] Max is not working for int32 _id Created: 07/Nov/23  Updated: 14/Nov/23  Resolved: 14/Nov/23

Status: Closed
Project: Entity Framework
Component/s: None
Affects Version/s: Public Preview 1
Fix Version/s: None

Type: Bug Priority: Major - P3
Reporter: Юрий Романов Assignee: Unassigned
Resolution: Duplicate Votes: 0
Labels: max
Remaining Estimate: Not Specified
Time Spent: Not Specified
Original Estimate: Not Specified

Issue Links:
Initiative
included in Initiative EF-77 Aggregate operations at top level Backlog

 Description   

Hello!

I've a very simple model:

 

public class MasterProduct
{
    [BsonId]
    [BsonRepresentation(BsonType.Int32)]
    public int Id { get; set; }
    public int Category { get; set; }
    public string Art { get; set; }
    public string Title { get; set; }
    public string HtmlDesc { get; set; }
    public string Slug { get; set; }
    public string[] Images { get; set; }
    public decimal BestPrice { get; set; }
} 

 

But when i want to retrive the latest ID:

   var data = _mongo.Products.AsNoTracking().Max(x => x.Id); 

i get:

ArgumentException: Expression of type 'Master.Models.MasterProduct' cannot be used for return type 'System.Int32' 



 Comments   
Comment by Damien Guard [ 13/Nov/23 ]

Hi, thanks for your issue.

The lack of Max/Min/Sum/Average etc. is a known limitation of preview 1 https://github.com/mongodb/mongo-efcore-provider#not-supported-but-considering-for-next-release and is planned for inclusion in a future update.

Generated at Thu Feb 08 08:26:50 UTC 2024 using Jira 9.7.1#970001-sha1:2222b88b221c4928ef0de3161136cc90c8356a66.