c# - 如何使用 slite-net 在 C# 中忽略列表?
问题描述
我正在尝试实现观察者设计模式,对于一个表,我需要一个观察者列表。但是,我不希望将其添加到表格中。我尝试使用 [Ignore] 但我收到此错误:
attribute 'ignore' is not valid on this declaration type. it is only valid on 'property, indexer' declarations. (cs0592) (core)
这是我的课(表是活动):
[PrimaryKey, AutoIncrement]
public int IDA { get; set; }
public String name { get; set; }
[Ignore] // this generates an error
public List<IObserver> observers;
解决方案
答案在错误信息中,这部分:it is only valid on 'property, indexer' declarations
使观察者成为一个属性,而不是一个字段(即添加{ get; set; }
到声明的末尾
推荐阅读
- asp.net-core - OpenIddict:使用默认的 Asp Net Core SDK 证书
- python - np.vectorize 和 np.apply_along_axis 将相同的参数两次传递给映射函数
- matlab - Matlab中级数求和的性能分析
- apache-kafka - Kafka 中每个主题的一个消费者线程针对多个分区是否会导致延迟?
- apache-spark - 无法启动 Spark
- magento - Magento Grunt 子主题编译无法更新合并的样式文件
- bash - 如何合并,连接,连接由下划线分隔的文本文件中的前两列?
- c# - 生成控制器时,“视图模型”需要主键”错误
- javascript - 无法读取 admin.firestore.collection.doc.get.then.doc 中未定义的属性“firstName”
- java - HTTP代码返回后如何通知客户端异常