I'm going to use Entity Framework soon for a Booking System ( made from scratch ).
I have been doing a few Prototypes, trying to figure out what I want to do before the project is started (I'm still discussing requirements etc. with the client).
Consider this case:
I have a Booking, and a booking can have associated Ressources, that can be booked, but these ressource can be different, and have different Fields etc.
I have never really used EF before, so I don't know how I can achieve this kind of Polymorphism, that I am use to in other projects (where we have been using raw SQL).
The C# Model would look like this:
public class Booking
{
public int BookingID { get; set; }
public DateTime StartTime { get; set; }
public DateTime EndTime { get; set; }
public IRessource Ressources { get; set; }
...
}
public interface IRessource
{
public int RessourceTypeId { get; set; }
}
public class Room : IRessource
{
public int RoomID { get; set; }
public int RessourceTypeId { get; set; }
...
}
public class Car : IRessource
{
public int CarID { get; set; }
public int RessourceTypeId { get; set; }
...
}
Is this achievable, and if yes, then how?
How would the querying even look?
See Question&Answers more detail:
os 与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…