1.定义泛型类 namespace Crm.Data.Logic.Repository{ public abstract class AbstractRepository<TC, T> : IDisposable where TC : DbContext, new() where T : class { private TC _entities = new TC(); private bool _disposed; …
Framework版本:.Net Framework 4 ConnectionUtil源码参见:https://www.cnblogs.com/threadj/p/10536273.html using System; using System.Collections.Generic; using System.Linq; using System.Web; using MongoDB.Driver; using MongoDB.Bson; using MongoDB.Driver.Builde…
约束 public abstract class BaseModel { public int Id { get; set; } } 连接字符串 public static readonly string Customers = ConfigurationManager.ConnectionStrings["Customers"].ToString(); 通用数据库字符串 public class SqlBuilder<T> where T : BaseModel { pu…