Quantcast
Channel: Xamarin.Forms — Xamarin Community Forums
Viewing all articles
Browse latest Browse all 58056

Database - Problem storing inherited parameters from abstract class

$
0
0

Lets say I've this Abstract class called Accident and a subclass CarAccident:

public abstract class Accident : IComparable< Accident >, IComparable {
        public Int16 AccidentID;
        public DateTime Date;
        public String Location;

        public Accident(Int16 _AccidentID,DateTime _Date, String Location )
        {
            this. AccidentID = _ AccidentID;
            this.Date = _Date;
            this.Location = _Location
        }

        int IComparable.CompareTo(object other) {
            return CompareTo((Accident)other);
        }
        public int CompareTo(Accident other){
            return this.Date.CompareTo(other.Date);
        }

        public Accident()
        {}
}

public class CarAccident : Accident
    {
        public CarAccident ()
        {
        }

        public CarAccident (Int16 _AccidentID,DateTime _Date , string _Location, Int16 _CarAttribute1, Int16 _CarAttribute2):base(_AccidentID,_Date, _Location)
        {
            this. AccidentID = _ AccidentID;
            this.Date = _Date;
            this.Location = _Location;
            this.CarAttribute1 = _CarAttribute1
                this.CarAttribute2 = _CarAttribute

        }

        [PrimaryKey, AutoIncrement]
        public Int16 CarID{ get; set;}
        public Int16 CarAttribute1{ get; set;}
        public Int16 CarAttribute2{ get; set;}
    }
}

So my problem is that once I try to store the instances of CarAccident in my SQLite database the attributes inherited from the Accident class are not stored... I suppose I've missed something crucial? Any suggestions?


Viewing all articles
Browse latest Browse all 58056

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>