小编Dev*_*pex的帖子

实体框架中的级联删除(每类继承的表)

我有DB模型与每种类型的表继承.例如,实体是A,B,C,A1,A2.基础 - 衍生 - A1,A2.另一个 - B,C.因此,A与A1和A2具有1对1的关联.B和C分别与A1和A2有关联(1到多个,在DB侧有OnDelete动作).

问题

我试图从B中删除记录,所以我希望EF也删除与当前B记录相关的所有A1对象.

最后,EF从B中删除记录,从A1中删除所有相关记录,但不从A中删除

为什么?如何解决?

.net c# entity-framework

13
推荐指数
1
解决办法
4670
查看次数

触发器中的只读附加属性 (WPF)

我有只读附加属性的问题。我是这样定义的:

public class AttachedPropertyHelper : DependencyObject
{

    public static readonly DependencyPropertyKey SomethingPropertyKey = DependencyProperty.RegisterAttachedReadOnly("Something", typeof(int), typeof(AttachedPropertyHelper), new PropertyMetadata(0));

    public static readonly DependencyProperty SomethingProperty = SomethingPropertyKey.DependencyProperty;

}
Run Code Online (Sandbox Code Playgroud)

我想在 XAML 中使用它:

<Trigger Property="m:AttachedPropertyHelper.Something" Value="0">
                        <Setter Property="FontSize" Value="20"/>
                    </Trigger>
Run Code Online (Sandbox Code Playgroud)

但是编译器不想使用它。结果,我有两个错误:

在“ReadonlyAttachedProperty.AttachedPropertyHelper”类型上找不到样式属性“Something”。第 11 行位置 16。

在类型“TextBlock”中找不到属性“Something”。

c# wpf triggers readonly attached-properties

6
推荐指数
1
解决办法
3008
查看次数