Support complex properties on owned types in JSON-mapped owned collections

オープン
#39,692 コメント 0 件 リアクション 0 件 担当者 0 名 GitHub で見る

メンテナーはふだん 2 日以内に返信

まだ誰も着手していません。

評価

難易度
4/5
見積もり時間
3〜5日
初心者へのやさしさ
52/100
issue の種類
機能追加
明瞭さ
明確に書かれている
活発さ
活発
技術スタック
csharp

調査の方向性

Start by reading the discussion on PR #39522, which this issue says must merge first, then trace EF Core's model validation for complex properties mapped inside JSON owned collections. Check the tests for JSON-mapped owned collections and nested owned types. Done means complex properties work for the described nesting patterns and the model validation error no longer blocks them.

索引モデルが issue の本文から書いたものです。

説明

area-complex-types area-owned-entities

Follow up to #39522. Filing this issue now to include the id as a comment, not relevant until that PR is merged.

public class Order
{
    public int Id { get; set; }
    public List<OrderLine> Lines { get; set; } = [];
}

public class OrderLine
{
    public string Sku { get; set; }
    public Money Price { get; set; }
}

public class Money
{
    public decimal Amount { get; set; }
    public string Currency { get; set; }
}
modelBuilder.Entity<Order>().OwnsMany(
    o => o.Lines, b =>
    {
        b.ToJson();
        b.ComplexProperty(l => l.Price);
    });

Expected: Price is stored in each element of the Lines JSON array, as it is for OwnsOne(...).ToJson().

Actual: model validation throws:

Complex property 'OrderLine.Price' cannot be declared on 'OrderLine', which is mapped to JSON as part of an owned collection. Complex properties on owned types in JSON collections aren't supported; map the collection with 'ComplexCollection(...).ToJson()' instead.

The same applies to any owned type below a JSON owned collection: an OwnsOne nested in OwnsMany(...).ToJson(), and an OwnsMany nested in OwnsOne(...).ToJson().

主要言語
C#
スター
14.8k
フォーク
3.5k
平均マージ
3日 7時間
マージ済み PR(30日)
182

環境構築

Codespaces で開く

このプロジェクトの開発コンテナを、あなたの GitHub アカウントでブラウザ上に起動します。

はじめの一歩

  1. issue を最後まで読み、次にプロジェクトのコントリビューションガイドを読みます。
  2. 着手することを issue にコメントします — 二人が同じ作業をするのを防げます。
  3. リポジトリをフォークし、ブランチを切って変更します。
  4. issue 番号を参照したプルリクエストを送ります。

dotnet/efcore のほかの issue

dotnet/efcore の issue をすべて見る

似ている issue

C# の issue をもっと見る

新しい issue をメールで受け取る

初心者向けの GitHub issue を短くまとめたダイジェスト。