 
        using System.Collections.Generic;
using System.Data.Entity;
using Omu.ProDinner.Core.Model;
using Omu.ProDinner.Core.Repository;
namespace Omu.ProDinner.Data
{
    public class UniRepo : IUniRepo
    {
        private readonly DbContext c;
        public UniRepo(IDbContextFactory a)
        {
            c = a.GetContext();
        }
        public void Insert<T>(T o) where T : Entity
        {
            c.Set<T>().Add(o);
        }
        public void Save()
        {
            c.SaveChanges();
        }
        public T Get<T>(int id) where T : Entity
        {
            return c.Set<T>().Find(id);
        }
        public IEnumerable<T> GetAll<T>() where T : Entity
        {
            return c.Set<T>();
        }
    }
}
为什么要用泛型呢? 指明类型不好吗?
这个问题基本上可以当作“泛型有什么好处”来回答。很明显你的例子中,Entity可能是任何数据库对象的映射,比如UserEntity(表示一个User,对应数据库表Users中的一行),OrderEntity等。泛型的好处就是做到算法上的归纳。比如你要新建一个用户,就是c.Set<User>.Add(user); 新增一个订单,就是c.Set<Order>.Add(order); 使用泛型T之后,Insert方法可以处理所有类似的情况,一句c.Set<T>.Add(o); 就可以了。如果指定类型,那么几乎同样的代码对User和Order要分别实现一遍,做了重复劳动并且不利于维护。当然了,如果User和Order的插入逻辑不同(也就是说无法做到算法上的归纳),那就要分开实现了。
简单的讲,用泛型的好处就是做到算法重用。