问题描述
SQLite-net 用来表示表的类中使用的数据类型有哪些限制?具体来说,我可以用这个吗:
What limitations are there on data types used in a class that will be used by SQLite-net to represent a table? Specifically, can I use this:
public List<string> CoconutWaterBrands { get; set; }
...或者我需要这个:
...or will I need this:
public string[] CoconutWaterBrands { get; set; }
...还是其他?
推荐答案
ORM(又名抽象泄漏)会出现这种问题.类中的字段将对应于表中的列.如果您使用列表或数组,那么 ORM 将不得不以某种方式将列表中的这些值组合在一个列中,因为它必须选择某种分隔符,如果分隔符出现在您的字符串值中怎么办,最终您将在兔子洞里慢慢找到自己.
ORMs (aka abstraction leak) will have this kind of problem. The fields in the class will correspond to columns in the table. If you use List or arrays then the ORM will either have to somehow combine those values in the list in a single column, for that it will have to choose some kind of separator and what if the separator appears inside your string value, ultimately you will slowly find your self in rabbit hole.
我认为 SQLite-net 不支持数组/列表.您将需要使用字符串(并根据需要拆分和连接它)或创建一个新表来表示一对多关系.
I don't think SQLite-net support arrays/list. You will need to use string (and split and join it as required) or create a new table to represent the one-to-many relationship.
这篇关于我可以在用于 SQLite 的类中使用字符串列表吗?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持编程学习网!