具有临时字段的ServiceStack Ormlite类

时间:2015-01-07 08:16:59

标签: c# servicestack ormlite-servicestack

是否可以在ServiceStack OrmLite POCO类中定义临时字段来保存数据(不在表模式中)?

1 个答案:

答案 0 :(得分:3)

绝对。您只需在不属于架构的属性上添加[Ignore]属性即可。

From the documentation:

  

忽略DTO属性

     

您可以使用[忽略]属性来表示不是表中字段的DTO属性。这将强制SQL生成忽略该属性。

示例:

public class MyTable
{
    public int Id { get; set; }
    public string Name { get; set; }

    [Ignore]
    public string ExtraData { get; set; } // This field will not be included in SQL
}
相关问题