c# - Generic entity for raw queries in Entity Framework -
i using ef , have execute custom queries user can create need.
i know raw queries have use sqlquery
, not know object query returns.
i using unitofwork
pattern:
public class repository<tentity> : irepository<tentity> tentity:class { cellularfivelocalentities context = null; public repository() { context = new cellularfivelocalentities(); } private dbset<tentity> entityset { { return context.set<tentity>(); } } public list<string> rawquery(string query) { list<string> result = null; try { var entity = context.set<string>(); result = entity.sqlquery(query).tolist(); } catch (exception ex) { throw ex; } return result; } public void dispose() { if (context != null) { context.dispose(); } } }
how can use generic object custom queries?
Comments
Post a Comment