【问题标题】:ServiceStack OrmLite: Table field type when create table form c#ServiceStack OrmLite:创建表格时的表格字段类型c#
【发布时间】:2017-04-05 05:25:00
【问题描述】:
键入“文本”时我需要创建表格字段。
public class PropsTable {
public string PropKey { get; set; }
public string PropValue { get; set; }
}
....
db.CreateTableIfNotExists<PropsTable>();
当我这样做时:varchar(255)
然后您可以决定如何执行此操作?
谢谢。
【问题讨论】:
标签:
mysql
servicestack
ormlite-servicestack
【解决方案1】:
告诉 OrmLite 创建带有大文本字段的表的通用(即跨 RDBMS)方法是使用[StringLength(StringLengthAttribute.MaxText)],例如:
public class PropsTable
{
public string PropKey { get; set; }
[StringLength(StringLengthAttribute.MaxText)]
public string PropValue { get; set; }
}
对于特定于 RDBMS 的列定义,您可以使用 [CustomField],例如:
[CustomField("text")]
public string PropValue { get; set; }