2017-04-04 40 views
1

我需要創建表格字段時鍵入「文本」。ServiceStack OrmLite:表格字段類型創建表格時c#

public class PropsTable { 
    public string PropKey { get; set; }   
    public string PropValue { get; set; } 
} 
.... 

db.CreateTableIfNotExists<PropsTable>(); 

當我做這種類型:VARCHAR(255)

你可以決定如何做到這一點?

謝謝。

回答

2

通用(即跨RDBMS)的方式來告訴OrmLite創建表的大文本字段是使用[StringLength(StringLengthAttribute.MaxText)],如:

public class PropsTable 
{ 
    public string PropKey { get; set; }   

    [StringLength(StringLengthAttribute.MaxText)] 
    public string PropValue { get; set; } 
} 

對於您可以使用[CustomField] RDBMS特定的列定義,例如:

[CustomField("text")] 
public string PropValue { get; set; } 
+1

謝謝!是工作! ) –