SQLite - Column in SELECT but not in INSERT or UPDATE

MarioJuniorMarioJunior Mario JuniorUSMember ✭✭

Hello,

I'm working with SQLite ORM, and my Tables are created based on my Business Objects (Models), but I have some Properties on Models that are mapped to another tables (obtained using Foreign Key columns).

Example:

[Table("SalesOrder")]
public class SalesOrder
{
    public int OrderID { get; set; }
    public int CustomerID { get; set; }
    // ...
    [Ignore]
    public string CustomerName { get; set; }
}

[Table("Customer")]
public class Customer
{
    public int CustomerID { get; set; }
    public string CustomerName { get; set; }
}

And I'm using the Query<T>() method to retrieve information:

this.dbConnection.Query<SalesOrder>("SELECT SalesOrder.OrderID,SalesOrder.CustomerID,Customer.CustomerName FROM SalesOrder INNER JOIN Customer ON SalesOrder.CustomerID=Customer.CustomerID");

But the CustomerName property of the SalesOrder class are always null, because I've used the [Ignore] attribute.

If I omit the [Ignore] attribute, it gets the CustomerName, but it also create a CustomerName field in the SalesOrder table, when I call the CreateTable<T>() method, and uses this fields on Insert and Update operations.

Can I omit the use of this field / property on CreateTable, Insert and Update, and uses only on Select / Query methods?

Sign In or Register to comment.