【问题标题】:ServiceStack Ormlite class with temporary field带有临时字段的 ServiceStack Ormlite 类
【发布时间】:2015-01-07 17:01:07
【问题描述】:

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

【问题讨论】:

    标签: c# servicestack ormlite-servicestack


    【解决方案1】:

    当然。您可以简单地在不属于您的架构的属性上添加一个[Ignore] 属性。

    From the documentation:

    忽略 DTO 属性

    您可以使用 [Ignore] 属性来表示不是表中字段的 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
    }
    

    【讨论】:

      猜你喜欢
      • 2015-05-28
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2014-08-17
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多