Beispiel #1
0
 public bool Insert(User_MODEL model) {
     using (EFDataContext dataContext = new EFDataContext()) {
         dataContext.User.Add(model);
         dataContext.SaveChanges();
         return true;
     }
 }
Beispiel #2
0
 public bool Update(MODEL.User_MODEL model) {
     using (EFDataContext dataContext = new EFDataContext()) {
         dataContext.Entry(model).State = EntityState.Modified;
         dataContext.SaveChanges();
         return true;
     }
 }
Beispiel #3
0
 /// <summary>
 /// 更新用户姓名
 /// userModel 包含了已更新的Name
 /// </summary>
 /// <param name="userModel"></param>
 /// <returns></returns>
 public bool UpdateName(MODEL.User_MODEL userModel) {
     using (EFDataContext dataContext=new EFDataContext()) {
         dataContext.User.Attach(userModel);
         dataContext.Entry(userModel).Property(one => one.Name).IsModified = true;
         dataContext.SaveChanges();
         return true;
     }
 }
Beispiel #4
0
 public bool Delete(int id) {
     using (EFDataContext dataContext=new EFDataContext()) {
         MODEL.User_MODEL userModel = dataContext.User.Find(id);
         if (userModel != null) {
             dataContext.User.Remove(userModel);
             dataContext.SaveChanges();
             return true;
         }
         return false;
     }
 }
Beispiel #5
0
 /// <summary>
 /// 根据主键ID查找实体,然后更新其Name属性
 /// </summary>
 /// <param name="id"></param>
 /// <param name="name"></param>
 /// <returns></returns>
 public bool UpdateName(int id, string name) {
     using (EFDataContext dataContext = new EFDataContext()) {
         MODEL.User_MODEL userModel = dataContext.User.Find(id);
         if (userModel != null) {
             dataContext.User.Attach(userModel);
             userModel.Name = name;
             dataContext.SaveChanges();
         }
         return true;
     }
 }
        public ActionResult Index()
        {
            _ctx = new EFDataContext();
            var client = new Client("juan", "Ruiz", "brum", "095699447");
            var pet = new Pet("arya", "9 meses", PetType.Cat);

            _ctx.Pets.Add(pet);
            client.Pets.Add(pet);
            _ctx.Clients.Add(client);

            _ctx.SaveChanges();

            return View();
        }
Beispiel #7
0
        static void Main(string[] args)
        {
            using (var context = new Model1Container())
            {
                IDataContext dataContext = new EFDataContext(context);
                IEmployeeRepository employeeRepo = new EmployeeRepository(dataContext);
                IEmailService emailService = new EmailService();

                string ceoEmail = "*****@*****.**";

                var task = new EmployeeBirthdayMailerTask(employeeRepo, emailService, ceoEmail);

                task.SendBirthdayGreetings(DateTime.Now.AddDays(1));
            }
        }
 public EFMemberRepository(EFDataContext context)
 {
     _context = context;
 }
Beispiel #9
0
 public CarsController(EFDataContext context, IWebHostEnvironment webHostEnvironment)
 {
     _context            = context;
     _webHostEnvironment = webHostEnvironment;
 }
Beispiel #10
0
 public EFUnitOfWork(IConnectionStringProvider <string> connectionStringProvider, IMapper mapper)
 {
     _db         = new EFDataContext(connectionStringProvider);
     Employees   = new EFRepository <Employee, EmployeeEntity>(_db, mapper);
     Departments = new EFRepository <Department, DepartmentEntity>(_db, mapper);
 }
 public CompetitionSubjectsController(EFDataContext context)
 {
     _context = context;
 }
Beispiel #12
0
 public RepositoryUser(EFDataContext dbContext,
                       IOptions <jwtCredentials> jwtCredentialsOptions)
 {
     _dbContext      = dbContext;
     _jwtCredentials = jwtCredentialsOptions.Value;
 }
Beispiel #13
0
 public PutWindow(long res, EFDataContext context)
 {
     InitializeComponent();
     _res     = res;
     _context = context;
 }
Beispiel #14
0
 public UserService()
 {
     _context = new EFDataContext();
 }
Beispiel #15
0
 public int GetRecordCount(Where objWhere = null) {
     using (EFDataContext dataContext = new EFDataContext()) {
         if (objWhere == null) {
             objWhere = new Where().Add(new Where.Item("1", "=", "1"));
         }
         return dataContext.Database.SqlQuery<int>(
             $"select count({PrimaryKey}) from {TableName} where {objWhere.Result}",
             CreateWhereSqlParameters(objWhere)).First();
     }
 }
Beispiel #16
0
        public DataTable GetDataTable(string fields = "*", Where objWhere = null, string orderField = null,
            bool asc = true, int pageIndex = 0,
            int pageSize = 10) {
            using (EFDataContext dataContext = new EFDataContext()) {

                orderField = orderField ?? PrimaryKey;
                string sortDirection = asc ? "asc" : "desc";
                string orderby = $" {orderField} {sortDirection} ";

                if (objWhere == null) {
                    objWhere = new Where().Add(new Where.Item("1", "=", "1"));
                }
                string sql = $"select {fields} from {TableName} where {objWhere.Result}";
                const string sqlPageBase = @"select * from( 
                            select *,ROW_NUMBER() OVER (ORDER BY {1}) as rank from ({0})a 
                          )as t where t.rank between {2} and {3}";

                int startPageIndex = pageIndex*pageSize + 1;
                int endPageIndex = pageIndex*pageSize + pageSize;

                string sqlPage = string.Format(sqlPageBase, sql, orderby, startPageIndex, endPageIndex);
                return dataContext.Database.SqlQueryForDataTatable(sqlPage, CreateWhereSqlParameters(objWhere));
            }
        }
Beispiel #17
0
        public List<MODEL.User_MODEL> GetList( Where objWhere = null, string orderField = null, bool asc = true,
            int pageIndex = 0, int pageSize = 10) {
            using (EFDataContext dataContext = new EFDataContext()) {

                orderField = orderField ?? PrimaryKey;
                string sortDirection = asc ? "asc" : "desc";
                string orderby = $" {orderField} {sortDirection} ";

                string where = (objWhere == null) ? "1=1" : objWhere.Result;
                string sql = $"select * from {TableName} where {where}";
                const string sqlPageBase = @"select * from( 
                            select *,ROW_NUMBER() OVER (ORDER BY {1}) as rank from ({0})a 
                          )as t where t.rank between {2} and {3}";

                int startPageIndex = pageIndex*pageSize + 1;
                int endPageIndex = pageIndex*pageSize + pageSize;

                string sqlPage = string.Format(sqlPageBase, sql, orderby, startPageIndex, endPageIndex);
                return (objWhere == null)
                    ? dataContext.Database.SqlQuery<MODEL.User_MODEL>(sqlPage)
                        //.Select(data => new User_MODEL() {Name = data.Name})//选取需要的字段
                        .ToList()
                        
                    : dataContext.Database.SqlQuery<MODEL.User_MODEL>(sqlPage, CreateWhereSqlParameters(objWhere))
                        //.Select(data => new User_MODEL() {Name = data.Name})
                        .ToList();
            }
        }
Beispiel #18
0
 public MainWindow()
 {
     InitializeComponent();
     _context = new EFDataContext();
     _window  = new WindowModel();
 }
Beispiel #19
0
 public UnitOfWork()
 {
     _context = new EFDataContext();
 }
Beispiel #20
0
 public EFUnitOfWork(string connectionString)
 {
     db = new EFDataContext(connectionString);
 }
 public PersonController(EFDataContext dbcontext)
 {
     _dbContext = dbcontext;
 }
Beispiel #22
0
 public EFPurchaseRepository(EFDataContext context)
 {
     _context = context;
 }
Beispiel #23
0
 public CatService()
 {
     _context = new EFDataContext();
 }
 public CompetitionFieldsController(EFDataContext context)
 {
     _context = context;
 }
 public EFEntrustRepository(EFDataContext context)
 {
     _context = context;
 }
Beispiel #26
0
 public CompetitionBranchesController(EFDataContext context)
 {
     _context = context;
 }
 public EFProductRepository(EFDataContext context)
 {
     _context = context;
 }
 public SupporterUsersController(EFDataContext context)
 {
     _context = context;
 }
 public IrpfRepository()
 {
     _db = new EFDataContext();
 }
Beispiel #30
0
 public ProductRepository(EFDataContext context)
 {
     this.db = context;
 }
Beispiel #31
0
 public EFWarehouseRepository(EFDataContext context)
 {
     _context     = context;
     _setWerhouse = _context.Warehouse;
 }
 public EFMemberRepository(EFDataContext dBContext)
 {
     _dBContext = dBContext;
 }
 public EFBookCategoryRepository(EFDataContext dBContext)
 {
     _dBContext = dBContext;
 }
Beispiel #34
0
 public SupporterUsersController(EFDataContext context, UserManager <Models.User> userManager)
 {
     _context     = context;
     _userManager = userManager;
 }
Beispiel #35
0
 public static void SeedAll(EFDataContext context)
 {
     SeedCats(context);
 }
Beispiel #36
0
 public UserService(EFDataContext context)
 {
     _context = context;
 }
 public EFGoodRepository(EFDataContext dataContext)
 {
     _dataContext = dataContext;
 }
Beispiel #38
0
 public bool Delete(MODEL.User_MODEL userModel) {
     using (EFDataContext dataContext=new EFDataContext()) {
         dataContext.User.Attach(userModel);
         dataContext.User.Remove(userModel);
         dataContext.SaveChanges();
         return true;
     }
 }
 public RegistrationHandler(EFDataContext context, UserManager <AppUser> userManager, IJwtGenerator jwtGenerator)
 {
     _context      = context;
     _userManager  = userManager;
     _jwtGenerator = jwtGenerator;
 }
Beispiel #40
0
 public MODEL.User_MODEL GetOne(int id) {
     using (EFDataContext dataContext = new EFDataContext()) {
         return dataContext.User.Find(id);
     }
 }
Beispiel #41
0
 public ParticipantsController(EFDataContext context)
 {
     _context = context;
 }
Beispiel #42
0
 // GET: Shop
 public ProductController(EFDataContext db)
 {
     this._db = db;
 }