I’m trying to add EF entity set to dictionary as shown in following code:
private static readonly Dictionary<string, ObjectSet<EntityObject>> Gateways
= new Dictionary<string, ObjectSet<EntityObject>>
{
{"PlanSection", ModelEntities.PlanSection}
};
but compiler is saying:
cannot convert from 'System.Data.Objects.ObjectSet<MathApplication.Models.PlanSection>' to 'System.Data.Objects.ObjectSet<System.Data.Objects.DataClasses.EntityObject>'
PlanSection is the class mapped from the database table. What’s wrong in my code?
EDIT
Here is PlanSection definition:
public partial class PlanSection : EntityObject
Do you really need the Dictionary to contain an ObjectSet or is it enough to have the list of entities there.
If the list of entities is enough then why not just set the member to be IEnumerable and then add as the value ModelEntities.PlanSection.LoadAll() or something.
If your intention is to have all the objectsets united in that dictionary, then try creating an Interface that will be implemented by all your entities and then set the value Type of the dictionary to something like IEnumerable.
Or, the other way arround would be to try creating a dictionary which has a dynamic type as the value and then the compiler will leave you alone i think, but you will have other problems when using the values inside of the dictionary since you have to cast them to be able to access properties at design time.