I need a function to get a key-value pair of Id
and Description
from a entity model for populating some fields on a user control and I'd like to find a way to make it dynamic in order to avoid repeating code.
My pseudo-code:
public List<object> GetData(string modelName, string modelId, string modelDescription)
{
using(DbEntities context = new DbEntities())
{
return (from d in context.modelName
select new {
id=d.modelId,
description = d.modelDescription
}
).ToList<object>();
}
}
A possible partial solution could be this, but the table needs to be dynamically defined too.