示例#1
0
        public IEnumerable <TEntity> SearchAndRead(RpcFilter filter)
        {
            var entitesObject = connection.SearchAndRead(model, filter.ToArray(), propertiesName).ToXmlRpcStructList();
            var entities      = entitesObject.ToEntityList <TEntity>();

            return(entities);
        }
示例#2
0
        public RpcContext(RpcConnection rpcConnection, string modelName)
        {
            _rpcConnection = rpcConnection;
            _rpcModel      = new RpcModel(modelName, _rpcConnection);

            _records    = new List <RpcRecord>();
            RpcFilter   = new RpcFilter();
            _fieldNames = new List <string>();
        }
示例#3
0
        public TEntity Get(int id)
        {
            var filter = new RpcFilter().Equal("id", id).ToArray();
            var entity = connection.SearchAndRead(model, filter, propertiesName, limit: 1)
                         .ToXmlRpcStructList()
                         .ToEntityList <TEntity>()
                         .FirstOrDefault();

            return(entity);
        }
示例#4
0
        /// <summary>
        /// Total record count
        /// </summary>
        /// <returns></returns>
        public int Count()
        {
            if (!_rpcConnection.Login())
            {
                _rpcConnection.Login();
            }

            var filter = RpcFilter.ToArray();

            return(_rpcModel.Count(filter));
        }
示例#5
0
        public IEnumerable <RpcRecord> Execute(bool read = false, int offset = 0, int?limit = null)
        {
            if (!_rpcConnection.Login())
            {
                _rpcConnection.Login();
            }

            var fieldsResult = GetFields();

            if (_fieldNames.Count == 0)
            {
                _fieldNames = fieldsResult.Select(f => f.FieldName).ToList();
            }

            _rpcModel.AddFields(_fieldNames);

            return(_records = !read?_rpcModel.Search(RpcFilter.ToArray()) : _rpcModel.SearchAndRead(RpcFilter.ToArray(), fieldsResult, offset, limit));
        }