ipln
ipln

Reputation: 113

ServiceStack Ormlite class with temporary field

Is it possible to define temporary fields to hold data (that are not in the table schema) in a ServiceStack OrmLite POCO class?

Upvotes: 2

Views: 247

Answers (1)

Scott
Scott

Reputation: 21501

Absolutely. You can simply add an [Ignore] attribute on the properties that are not part of your schema.

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.

Example:

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
}

Upvotes: 3

Related Questions