I'm trying to wrap my head around the Entity Framework and am having trouble understanding how one would code to an interface (or, perhaps, whether coding to the interface is possible). I'm fairly confident in C#, but mostly due to my ability to program in so many other languages, so forgive any ignorances.
Given:
public interface IInputSource
{
float GetCurrentValue(DateTime timestamp);
}
public class PatternSource : IInputSource
{
…
float GetCurrentValue(DateTime timestamp)
{
// generate value based on probability equation
}
…
}
public class TimeSeriesSource : IInputSource
{
…
float GetCurrentValue(DateTime timestamp)
{
// look up value in a key/value store
}
…
}
I want to code a node class to the interface, since there are 5 or 6 distinctly different source types:
public class Node
{
…
public IInputSource Inflow { get; set;}
…
}
It seems that the O/M from Entity Framework would never be able to resolve the concrete class that Node would be referencing, and as such, one would simply not be able to code to an interface. Is this indeed the case?
If not, can someone give me an example of how this would be accomplished in EF 4? I'm using VS2010 & .NET 4 and I'm coming from a code-first mentality).