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

What is wrong with this model

    XMLWordPrintableJSON

Details

    • Icon: Bug Bug
    • Resolution: Unresolved
    • Icon: Major - P3 Major - P3
    • None
    • Public Preview 1
    • None

    Description

      Hello, i'm using EF in my F#\C# project.

      The model is simple:

       

      [<CLIMutable>]
      type EditorData = {
          text:string
      }
       
      [<CLIMutable>]
      type EditorBlock = {
          id:string
          ``type``:string
          data: EditorData
      }
       
      [<CLIMutable>]
      type News = {
          [<BsonId>]
          [<BsonRepresentation(BsonType.Int32)>]
          Id:int
          Category:int
          User:int
          Title:string
          Slug:string
          Added:DateTime
          JsonContent:ResizeArray<EditorBlock>
      } 

      i've saved my data and MongoDB Compass shows this:

       

       

      {
        "_id": 1,
        "Added": {
          "$date": "2024-01-17T14:21:55.412Z"
        },
        "Category": 1,
        "Slug": "-",
        "Title": "Test News",
        "User": 1,
        "JsonContent": [
          {
            "id": "1FBsOgCe3H",
            "type": "paragraph",
            "data": {
              "text": "тестовый параграф"
            }
          },
          {
            "id": "ZNptxV9d72",
            "type": "paragraph",
            "data": {
              "text": "ещё один"
            }
          },
          {
            "id": "k_UNq6WE53",
            "type": "paragraph",
            "data": {
              "text": "third"
            }
          }
        ]
      } 

      if i try just to find record:

       

       

      InvalidOperationException: The LINQ expression 'o' could not be translated. Either rewrite the query in a form that can be translated, or switch to client evaluation explicitly by inserting a call to 'AsEnumerable', 'AsAsyncEnumerable', 'ToList', or 'ToListAsync'. See https://go.microsoft.com/fwlink/?linkid=2101038 for more information. 

      but if i remove data: EditorData from EditorBlock everything works

       

      thank you for any help

      Attachments

        Activity

          People

            damien.guard@mongodb.com Damien Guard
            romanov@outlook.com Юрий Романов
            Votes:
            1 Vote for this issue
            Watchers:
            2 Start watching this issue

            Dates

              Created:
              Updated:

              PagerDuty