简体   繁体   English

亚音速SimpleRepository可空字符串问题

[英]Subsonic SimpleRepository Nullable string problem

I am having a problem with subsonic simplerepository. 我在亚音速简单存储库中遇到问题。 I have a users class and it has some optional fields.these optional fields are of type string. 我有一个用户类,它有一些可选字段。这些可选字段是字符串类型。 As soon as I try to persist my object , if the optional fields are null , an exception is being thrown 一旦我尝试保留我的对象,如果可选字段为null,则会引发异常

I know string is already of type nullable so i cannot do something like nullable and string? 我知道字符串已经是可以为null的类型,所以我不能做类似nullable和string的操作? so what should i do in this case ? 那么在这种情况下我该怎么办?

Another option that I have at this point of time is , before persisting the object, check if the optional attributes are null if they are null, assign them some dummy data. 此时,我还有另一个选择,在持久化对象之前,如果可选属性为null,请检查它们是否为null,并为它们分配一些虚拟数据。 for example "abracadabra". 例如“ abracadabra”。 now whenever i am populating the objects back from the database i check if optional attributes have this value. 现在,每当我从数据库中填充对象时,我都会检查可选属性是否具有此值。 if they have this value I make the optional attributes empty in my class. 如果它们具有此值,则将我的类中的可选属性设为空。

ah! 啊! one more thing, please ! 请再做一件事! can i use ActiveRecord for winforms? 可以将ActiveRecord用于Winforms吗?

添加[SubSonicNullString]属性。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM