条件表达式

在Smark.Data中的条件表达式包含了比较多的数据操作,主要功能有:查询,删除,修改和统计等功能。而操作方式比较另类,在其他持化组件中往往是操作方法用带有条件参数,而Smark.Data则是直接在条件对象上调用相关操作方法。
        Expression exp = AccountState.accountID == e.ID;
        exp.Edit<AccountState>(d => { d.State = OnlineState.在线; d.IPAddress = e.Point.Address.ToString(); d.ModifyTime = DateTime.Now; });
  • 条件编写
            AsteriskTRUNK AT = (AsteriskTRUNK.iPAddress == ASTATE.IPAddress).ListFirst<AsteriskTRUNK>();
            PhoneTRUNK ptrunk = (PhoneTRUNK.prefix == Prefix & PhoneTRUNK.enabled == true).ListFirst<PhoneTRUNK>();

            Expression exp = new Expression();
            if (!string.IsNullOrEmpty(companyname))
                exp &= Entities.Customers.companyName.Match(companyname);
            
            return exp.List<Entities.Customers>();
  • 查询方法
        public IList<T> List<T>() where T : Mappings.DataObject, new()

        public IList<T> List<T>(Region region) where T : Mappings.DataObject, new()
      
        public IList<T> List<T>(Region region,string orderby) where T : Mappings.DataObject,new()
       
        public IList<T> List<T>(IConnectinContext cc) where T : Mappings.DataObject, new()
       
        public IList<T> List<T>(IConnectinContext cc,Region region) where T : Mappings.DataObject, new()
        
        public IList<T> List<T>(IConnectinContext cc, Region region, string orderby) where T : Mappings.DataObject,new()
       
        public T ListFirst<T>() where T : Mappings.DataObject, new()
        
        public T ListFirst<T>(IConnectinContext cc) where T : Mappings.DataObject, new()
        
        public T ListFirst<T>(string orderby) where T : Mappings.DataObject, new()
        
        public T ListFirst<T>(IConnectinContext cc, string orderby) where T:Mappings.DataObject,new()
  • 数据编辑方法
        public int Edit<T>(Action<T> handler) where T : DataObject, new()

        public int Edit<T>(IConnectinContext cc,Action<T> handler) where T : DataObject, new()

        public int Edit<T>(params Field[] fields) where T:DataObject,new()

        public int Edit<T>(IConnectinContext cc, params Field[] fields)  where T:DataObject,new()
       
  • 数据删除方法
        public int Delete<T>()

        public int Delete<T>(IConnectinContext cc)     
  • 数据统计方法
        public int Count<T>()

        public int Count<T>(IConnectinContext cc)

        public RESULT Sum<RESULT, Entity>(string field)

        public RESULT Sum<RESULT, Entity>(string field, bool DISTINCT)

        public RESULT Sum<RESULT, Entity>(string field, IConnectinContext cc)

        public RESULT Sum<RESULT, Entity>(string field, bool DISTINCT, IConnectinContext cc)

        public RESULT Max<RESULT, Entity>(string field)

        public RESULT Max<RESULT, Entity>(string field, bool DISTINCT)

        public RESULT Max<RESULT, Entity>(string field, IConnectinContext cc)

        public RESULT Max<RESULT, Entity>(string field, bool DISTINCT, IConnectinContext cc)

        public RESULT Min<RESULT, Entity>(string field)

        public RESULT Min<RESULT, Entity>(string field, bool DISTINCT)

        public RESULT Min<RESULT, Entity>(string field, IConnectinContext cc)

        public RESULT Min<RESULT, Entity>(string field, bool DISTINCT, IConnectinContext cc)

        public RESULT Avg<RESULT, Entity>(string field)

        public RESULT Avg<RESULT, Entity>(string field, bool DISTINCT)

        public RESULT Avg<RESULT, Entity>(string field, IConnectinContext cc)

        public RESULT Avg<RESULT, Entity>(string field, bool DISTINCT, IConnectinContext cc)

Last edited Jun 4, 2010 at 9:42 AM by smarkhenry, version 8

Comments

No comments yet.