protected override void ImplementBusinessLogic() { AutoViewFactory factory = new AutoViewFactory(this.Info.AppSqlCon, this); View view = factory.GetView(this.Option.SaveObj.ViewID); var sql = GetViewSql(view); global::Soway.Model.SqlServer.dbContext context = new global::Soway.Model.SqlServer.dbContext(sql, this); IObjectProxy iObjectProxy = new Soway.Model.ObjectProxy(view.Model, this); if (String.IsNullOrEmpty(this.Option.OwnerViewId) == false) { var ownerModel = factory.GetView(this.Option.OwnerViewId).Model; var owner = context.GetDetail(ownerModel, this.Option.OwnerId); Soway.Model.ModelBindingList array = owner[this.Option.Property] as Soway.Model.ModelBindingList; iObjectProxy = array.AddNew(); DataFormator.ObjUpdateToProxy(this.Option.SaveObj, iObjectProxy); context.Save(owner); //iObjectProxy.Owner = new ObjectProxy(ownerModel) { ID = this.Option.OwnerId ,SaveInDB=true,IsLoad= LoadType.Complete}; } else { DataFormator.ObjUpdateToProxy(this.Option.SaveObj, iObjectProxy); context.Create(iObjectProxy); } }
/// <summary> /// 这个函数是OK的 /// </summary> /// <param name="ob"></param> /// <param name="command"></param> private void ExuctePropertyModelMethod(IObjectProxy ob, ICommand command) { if (command.Property.IsArray == false) { DynamicObject proxy = ob[command.Property] as DynamicObject; object ob1 = new object(); proxy.TryInvokeMember(new ObjectInvokeMemberBinder(command.Exp), new object[] { } , out ob1); } else { ModelBindingList list = ob[command.Property] as ModelBindingList; object tempOb; foreach (DynamicObject item in list) { item.TryInvokeMember(new ObjectInvokeMemberBinder(command.Exp), new object[] { } , out tempOb); } } }