是否可以在 ServiceStack OrmLite POCO 类中定义临时字段来保存数据(不在表模式中)?
最佳答案
绝对是的。您只需在不属于架构的属性上添加[Ignore]
属性即可。
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/