c# - 带有临时字段的 ServiceStack Ormlite 类

标签 c# servicestack ormlite-servicestack

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

最佳答案

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

From the documentation:

Ignoring DTO Properties

You may use the [Ignore] attribute to denote DTO properties that are not fields in the table. This will force the SQL generation to ignore that property.

示例:

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
}

关于c# - 带有临时字段的 ServiceStack Ormlite 类,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/27815038/

相关文章:

c# - 如何用 "9HM.A2"声明锯齿状数组

c# - 我将如何使用委托(delegate)作为参数调用此函数

udp - 服务堆栈restful发现udp

mysql - ServiceStack ORMLite 未填充来自 MySQL 的结果

servicestack - 使用 ServiceStack.OrmLite ServiceStack 查询表时 MissingFieldException

c# - 是否可以映射到带有别名的枚举?

c# - 遍历列表并动态创建摘要行

c# - Entity Framework : Remove and Add entities with same key in a single request

c# - 从 Postgresql 数据库 ServiceStack.Ormlite 生成类对象

c# - 继承类型的 CSV 序列化