Beispiel #1
0
 public void onAfterEvent(ref object data, EFAction action)
 {
     if (AfterEvent != null)
     {
         AfterEvent.Invoke(this, new EFEventArgs(ref data, action));
     }
 }
Beispiel #2
0
 public void onBeforeEvent(ref object data, EFAction action)
 {
     if (BeforeEvent != null)
     {
         BeforeEvent.Invoke(this, new EFEventArgs(ref data, action));
     }
 }
Beispiel #3
0
        public ActionResult Menu()
        {
            List<CMS_CategoryModels> models = null;

            using (TransactionScope scope = new TransactionScope())// 事务对象
            {
                using (var ctx = new StarDBContext())
                {
                    EFAction<CMS_CategoryModels> model = new EFAction<CMS_CategoryModels>();
                    model.ctx = ctx;

                    models = model.GetAll().ToList();
                }
            }

            return View(GetMenu(models));
        }
Beispiel #4
0
        public void TestEF()
        {
            // Add Person To DB
            using (TransactionScope scope = new TransactionScope())// 事务对象
            {
                using (var ctx = new StarDBContext())
                {
                    //var person = new Person();
                    //person.FirstName = "Robbert2";
                    //person.MiddleName = "Allen2";
                    //person.LastName = "Doe2";
                    //content.Person.Add(person);

                    //var table1 = new Table1();
                    //table1.Field1 = "tt2";
                    //table1.Field2 = "ddd";
                    //table1.Field3 = "sss";
                    //ctx.Table2.Add(table1);
                    //ctx.SaveChanges();

                    // exe sql command
                    //var parameters = new DbParameter[]{
                    //    new SqlParameter(parameterName:"Field1",value:"tt"),
                    //    new SqlParameter(parameterName:"Field2",value:"ddd")
                    //};
                    //var result = new Table1();
                    var efAction = new EFAction<Table1>();
                    efAction.ctx = ctx;
                    var table1 = efAction.Get(1);
                    var efAction2 = new EFAction<Person>();
                    efAction2.ctx = ctx;
                    var person = efAction2.Get(1);
                    //var res = ctx.Database.SqlQuery<Table1>("select * from Table1 where Field1=@Field1 and Field2=@Field2", parameters).ToList();
                    //ctx.Person.Find(1);
                    var a = 1;
                }
            }
        }
 public EFEventArgs(ref object data, EFAction action)
 {
     Data   = data;
     Action = action;
 }
        public void onExceptionEvent(Exception e, EFAction action)
        {
            //if (ExceptionEvent != null)
            //    ExceptionEvent.Invoke(this, new EFEventArgs(ref e, action));

        }
        public void onAfterEvent(ref object data, EFAction action)
        {
            if (AfterEvent != null)
                AfterEvent.Invoke(this, new EFEventArgs(ref data, action));

        }
        public void onBeforeEvent(ref object data, EFAction action)
        {
            if (BeforeEvent != null)
                BeforeEvent.Invoke(this, new EFEventArgs(ref data, action));

        }
 public EFEventArgs(ref object data, EFAction action)
 {
     Data = data;
     Action = action;
 }
Beispiel #10
0
 public void onExceptionEvent(Exception e, EFAction action)
 {
     //if (ExceptionEvent != null)
     //    ExceptionEvent.Invoke(this, new EFEventArgs(ref e, action));
 }