1
考慮LoyaltyCard
數據庫DTO欄我有以下:ServiceStack OrmLite包括WHERE子句中,但不要選擇
[Alias("customer_ids")]
[CompositeIndex("id_code", "id_number", Unique = true)]
public class LoyaltyCard
{
[Alias("customer_code")]
public int CustomerId { get; set; }
[Alias("id_code")]
public string LoyaltyCardCode { get; set; }
[Alias("id_number")]
public string LoyaltyCardNumber { get; set; }
[Alias("date_issued ")]
public DateTime? IssueDate { get; set; }
[Alias("linked_id")]
public bool LinkedId { get; set; }
[Alias("positive_id")]
public bool PositiveId { get; set; }
}
我有CustomerId
作爲一個屬性,因爲我需要它被包含在生成的SQL的WHERE
子句中,但我不希望在結果集中也選擇該列。有沒有辦法將它包含在哪裏但將它從選擇中排除?
// I was hoping that result would not have a populated CustomerIds
var result = db.Select<LoyaltyCard>(id => id.LoyaltyCardCode == "PS" && id.CustomerId == customerCode);
我試着加入[Ignore]
屬性,但失敗與SqlException: Invalid column name 'CustomerId'
。