Uploaded image for project: 'Entity Framework'
  1. Entity Framework
  2. EF-72

Max is not working for int32 _id

    • Type: Icon: Bug Bug
    • Resolution: Duplicate
    • Priority: Icon: Major - P3 Major - P3
    • None
    • Affects Version/s: Public Preview 1

      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' 

            Assignee:
            Unassigned Unassigned
            Reporter:
            romanov@outlook.com Юрий Романов
            Votes:
            0 Vote for this issue
            Watchers:
            2 Start watching this issue

              Created:
              Updated:
              Resolved: