我在存儲來自我的抽象類的屬性時存在一些問題,構造函數似乎工作得很好。不過,我無法將基本屬性存儲在我的子類數據庫表中。在子類db-table中存儲基本抽象類屬性
public abstract class Vehicle : IComparable<Vehicle>, IComparable {
public Int16 VehicleID;
public DateTime ProductionDate;
public Vehicle(Int16 _ Vehicle ID,DateTime _ProductionDate)
{
this.AccidentID = _ AccidentID;
this.ProductionDate = _ProductionDate;
}
int IComparable.CompareTo(object other) {
return CompareTo((Vehicle)other);
}
public int CompareTo(Vehicle other){
return this.ProductionDate.CompareTo(other.ProductionDate);
}
public Vehicle()
{}
}
public class Car : Vehicle
{
public Car()
{
}
public Car (Int16 _VehicleID,DateTime _ProductionDate, Int16 _CarAttribute1, Int16 _CarAttribute2):base(_Vehicle ID,_ProductionDate)
{
this.AccidentID = _ AccidentID;
this.ProductionDate = _ProductionDate;
this.CarAttribute1 = _CarAttribute1
this.CarAttribute2 = _CarAttribute2
}
[PrimaryKey, AutoIncrement, Column("Attribute1")]
public Int16 CarAttribute1{ get; set;}
[Column("Attribute2")]
public Int16 CarAttribute2{ get; set;}
}
我對C#很新,所以一些指導讚賞:)我錯過了什麼?
1.您使用哪種框架來使用數據庫? 2.你有什麼問題與你的代碼?異常,數據庫中的錯誤或NULL數據? – ntl 2014-08-31 21:00:43
嗨,我使用單聲道和Xamarin IDE,我使用的組件稱爲SQLite.net異步(https://www.nuget.org/packages/SQLite.Net.Async-PCL/)基類屬性爲null在我的數據庫列。 – RaddyMcKey 2014-09-01 05:49:12