I\'m quite new to C# and currently developing an application using the EntityFramework. I would like to extend the functionality of the database context class, so that I can cal
I'd recommend (besides of reading about generics and C# in general) to configure the pool with desired types on run time, store them in dictionaries and use the Type as key, i.e. something along the following lines...:
//...
// configuration, maybe factor out to a dedicated class...
private readonly IDictionary m_SupportedPools =
new Dictionary();
// add this queryable, note that type inference works here
public void AddToPool(IQueryable p_Queryable)
{
m_SupportedPools.Add(typeof(T), p_Queryable);
}
public IQueryable GetPool()
{
IQueryable t_Set = null;
if (m_SupportedQueries.TryGetValue(typeof(T), out t_Set)) {
return t_Set as IQueryable;
} else {
return null;
}
}