Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/csharp/304.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
C# PostSharp MulticastAttribute不工作_C#_.net_Inotifypropertychanged_Postsharp - Fatal编程技术网

C# PostSharp MulticastAttribute不工作

C# PostSharp MulticastAttribute不工作,c#,.net,inotifypropertychanged,postsharp,C#,.net,Inotifypropertychanged,Postsharp,我在PostSharp和Entity Framework方面遇到了问题,因为PostSharp为私有字段生成“backingField”属性,并且它的EDM模型创建失败。我曾尝试使用MulticastAttributeUsageAttribute.AttributeTargets将其限制为属性。 但是这个代码: [NotifyPropertyChanged(), MulticastAttributeUsage(MulticastTargets.Property)] public abstract

我在PostSharp和Entity Framework方面遇到了问题,因为PostSharp为私有字段生成“backingField”属性,并且它的EDM模型创建失败。我曾尝试使用
MulticastAttributeUsageAttribute.AttributeTargets
将其限制为属性。 但是这个代码:

[NotifyPropertyChanged(), MulticastAttributeUsage(MulticastTargets.Property)]
public abstract class MetrologijaEntityBase 
{
    public Guid Id { get; set; }
    public string ExternalKey { get; set; }
}
这个密码呢

[NotifyPropertyChanged()]
[MulticastAttributeUsage(MulticastTargets.Property)]
public abstract class MetrologijaEntityBase 
{
    public Guid Id { get; set; }
    public string ExternalKey { get; set; }
}
给出的结果与不带
multicastatributeusage
属性的代码相同-“backingField”属性(包含所有getter和setter)仍然会为私有字段生成
MetrologijaEntityBase
是EF业务模型实体层次结构的基类。
在这种情况下我做错了什么?

[MulticastAttributeUsage]
更改了它应用于的
MulticastAttribute
的默认行为,并且应用于不从
MulticastAttribute
继承的类时没有任何效果。它可以用来更改您自己方面的默认行为。它不会更改应用于同一声明的方面的行为(通常可以通过更改方面本身的属性来实现)

[NotifyPropertyChanged]
是一个类型级方面,它应用于整个类型。通常不可能控制它对单个属性的操作,除非方面本身支持(NPC方面目前不支持)

作为解决方案,我建议在创建上述EF模型时,以编程方式忽略基于名称添加的属性