SubSonic SimpleRepository 存储成员类
我是 C# 和 Subsonic 的新手。我正在尝试解决以下情况:
public class UnknownInt {
public int val;
public bool known;
}
public class Record {
public int ID;
public UnknownInt data;
}
我正在使用 SimpleRepository。 有没有办法在将 UnknownInt 存储到 SQL 数据库(可能作为 XML 文本字段?)之前对其进行序列化?
我正在尝试构建一个调查问卷系统,用户可以在其中提供“整数”答案、“未知”答案,以及一个 Null 答案(问题尚未得到解答)
换句话说 - 我的 UnknownInt 类需要实现哪些接口才能符合资格并可转换为 SubSonic 3.0 Simple Repository?
干杯!
I'm new to C# and Subsonic. I'm trying to solve the following case:
public class UnknownInt {
public int val;
public bool known;
}
public class Record {
public int ID;
public UnknownInt data;
}
I'm using SimpleRepository.
Is there a way I can get UnknownInt serialized before storing it in the SQL database (perhaps as XML text field?)
I'm trying to build a questionnaire system in which a user can provide an 'integer' answer, an 'Unknown' answer, as well as a Null answer (question not answered yet)
In other words - what interfaces does my UnknownInt class need to implement in order to be eligible and convertible into SubSonic 3.0 Simple Repository?
Cheers!
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
我会这样做:
基本思想是拥有存储用户定义类型但对智能感知隐藏的列(System.ComponentModel.EditorBrowsable 属性)。
比你有一个复杂的类型(在这种情况下我更喜欢一个结构而不是一个类),它隐藏在 SubSonic 的简单存储库中。覆盖和运算符重载是可选的,但使使用此类型变得更容易。
用法示例:
I would do this:
The basic idea is to have to columns that store your userdefined type but are hidden from intellisense (System.ComponentModel.EditorBrowsable attribute).
Than you have a complex type (I prefer a struct rather than a class in this case) that is hidden from SubSonic's simple repository. The overrides and operator overloads are optional but make working with this type easier.
Example usage:
尝试使用可为空的 int (int?) 而不是 UnknownInt 类 - 您可以通过亚音速存储它。无需 XML 转换!
Try using a nullable int (int?) instead of you UnknownInt class - you can store it via subsonic. No XML conversion needed!