Is it possible to use something like this on the Internet: (my application is on asp.net mvc)
public static class DbUtil
{
public static int Insert(object o, string cs)
{
using (var conn = new SqlConnection(cs))
using (var cmd = conn.CreateCommand())
{
...
conn.Open();
return Convert.ToInt32(cmd.ExecuteScalar());
}
}
}
using:
public class Repository<T> : IRepository<T>
{
public virtual int Insert(T o)
{
return DbUtil.Insert(o, Cs);
}
}
and after injection of the designer into the service or controller
public MyController(
IRepository<Organization> organizationRepository)
{
this.organizationRepository = organizationRepository;
}
source
share