I have 4 subclasses: Video, Image, Noteand Form. Each of them contains different types of data. For example, the class Imagecontains the path to the image file on the properties of the disk and the image, and the class Formcontains the values of the form fields. However, the common element between each element is the GPS coordinates and title, so I have the following abstract base class:
public abstract class Content
{
public float? Latitude { get; set; }
public float? Longitude { get; set; }
public float? Heading { get; set; }
}
However, I am embarrassed about how to model this in a database. At the moment I have a table called Events(for an example, let's say it's a birthday) and table 4 ( Videos, Images, Notesand Forms). Each table has a foreign key mapped to a primary key Events.
Using LINQ-to-SQL, I get 5 classes for each table. This is normal if I need only one data type, for example Event.Images, but what I want to do is to calculate the total amount of “content” a Eventand get the GPS coordinates. I can easily calculate the quantity simply using Event.Images.Count() + Event.Videos.Count() + ..., but I cannot do the same for the GPS coordinates. Is it possible to somehow model the database so that I can use the base class for each element and still be able to get an individually strongly typed element when I need to see its data?
source
share