問題タブ [self-referencing-table]
For questions regarding programming in ECMAScript (JavaScript/JS) and its various dialects/implementations (excluding ActionScript). Note JavaScript is NOT the same as Java! Please include all relevant tags on your question; e.g., [node.js], [jquery], [json], [reactjs], [angular], [ember.js], [vue.js], [typescript], [svelte], etc.
ruby-on-rails - マルチネストされた自己参照の子関連付けでstrong_paramsを実行するにはどうすればよいですか?
したがって、子条件を持つ Group オブジェクトがあります。Condition オブジェクトには、条件の自己参照型の子関連付けもあります。
グループ has_many :条件
条件の所属先:グループには_多くの条件:条件
レベルごとに明示的にリストする必要のない強力なパラメーターで複数のレベルを指定する良い方法はありますか (複数のレベルなどがある場合があります)。
c# - EF Core one-way self referencing entity binding
I have set up a self referential entity using EF Core which looks like this:
Entity
Binding
I am retrieving these entities via an API and the current result looks something like this:
The problem I have with this is that the third item in the array is just the reverse of the second. Is there a way to avoid this so that I only have the parent -> child relationship rather than both parent -> child as well as child -> parent. The example above is a heavily cut-down version of what my API is actually returning so I want to reduce the unnecessary bloat as much as possible because there'll be a lot of relationships going on.
Ideally what I want is to just get rid of the ParentType property but still have the ChildTypes collection but I'm not sure how to define that in the model builder.
EDIT:
I have removed the fluent relationship as it's not needed. I've also tried the following:
(this.Items
is the DbSet by the way)
However this requires changing ChildTypes
to an IQueryable
and when I do that I get the following exception:
The type of navigation property 'ChildTypes' on the entity type 'DetailType' is 'EntityQueryable' which does not implement ICollection. Collection navigation properties must implement ICollection<> of the target type.
jpa - null 以外の自己参照エンティティをバインドするにはどうすればよいですか?
私はこのように見えるテーブルをバインドしようとしています
ご覧のように、
- 自己参照エンティティのように見えます
- の FK なし
parent_id
parent_id
null 可能ではなく、デフォルトは0
どうすればバインドできますか?
次のマッピングは問題ありませんか?
つまり、どのように にマップでき0
ますnull
か?