Example #1
0
        /// <summary>
        /// Query and return first data
        /// </summary>
        /// <typeparam name="T">Data type.</typeparam>
        /// <returns>First data</returns>
        public T QueryFirst <T>()
        {
            T target = _context.QueryDataDefineSingle <T>(DataEntityMapping.GetEntityMapping(typeof(T)), _level, _command, 0, null, null);

            Callback();
            return(target);
        }
Example #2
0
        /// <summary>
        /// Query and return data list
        /// </summary>
        /// <typeparam name="T">Data type.</typeparam>
        /// <param name="region">Query region</param>
        /// <param name="cancellationToken">CancellationToken.</param>
        /// <returns>Data list</returns>
        private async Task <List <T> > QueryListAsync <T>(Region region, CancellationToken cancellationToken = default(CancellationToken))
        {
            List <T> list = await _context.QueryDataDefineListAsync <T>(DataEntityMapping.GetEntityMapping(typeof(T)), _level, _command, region, null, null, cancellationToken);

            Callback();
            return(list);
        }
Example #3
0
        /// <summary>
        /// Query and return first data
        /// </summary>
        /// <typeparam name="T">Data type.</typeparam>
        /// <param name="cancellationToken">CancellationToken.</param>
        /// <returns>First data</returns>
        public async Task <T> QueryFirstAsync <T>(CancellationToken cancellationToken = default(CancellationToken))
        {
            T target = await _context.QueryDataDefineSingleAsync <T>(DataEntityMapping.GetEntityMapping(typeof(T)), _level, _command, 0, null, null, cancellationToken);

            Callback();
            return(target);
        }
Example #4
0
        /// <summary>
        /// Query and return data enumerable
        /// </summary>
        /// <typeparam name="T">Data type.</typeparam>
        /// <param name="region">Data region</param>
        /// <returns>Data enumerable</returns>
        private IEnumerable <T> Query <T>(Region region)
        {
            IEnumerable <T> enumable = _context.QueryDataDefineReader <T>(DataEntityMapping.GetEntityMapping(typeof(T)), _level, _command, region, null, null);

            Callback();
            return(enumable);
        }
Example #5
0
        /// <summary>
        /// Query and return data list
        /// </summary>
        /// <typeparam name="T">Data type.</typeparam>
        /// <param name="region">Query region</param>
        /// <returns>Data list</returns>
        private List <T> QueryList <T>(Region region)
        {
            List <T> list = _context.QueryDataDefineList <T>(DataEntityMapping.GetEntityMapping(typeof(T)), _level, _command, region, null, null);

            Callback();
            return(list);
        }
Example #6
0
        public SingleParameterLambdaState(ParameterExpression parameter)
        {
            _singleEntityName = parameter.Name;
            var entityMapping = DataEntityMapping.GetEntityMapping(parameter.Type);

            _singleEntityMap = entityMapping.GetRelationMap();
        }
Example #7
0
        public RelateParameterLambdaState(ParameterExpression parameter, LambdaState state)
        {
            var entityMapping = DataEntityMapping.GetEntityMapping(parameter.Type);

            _singleEntityName = parameter.Name;
            _singleEntityMap  = entityMapping.GetRelationMap();
            _state            = state;
        }
Example #8
0
        public SingleParameterLambdaState(ParameterExpression parameter)
        {
            this.singleEntityName = parameter.Name;
            Type type = parameter.Type;
            DataEntityMapping entityMapping = DataEntityMapping.GetEntityMapping(type);

            this.singleEntityMap = entityMapping.GetRelationMap();
        }
Example #9
0
        protected virtual void InitialRelateMappingInc()
        {
            DataEntityMapping mapping = DataEntityMapping.GetEntityMapping(this.relateType);

            DataFieldInfo []    infos  = new DataFieldInfo [keyPairs.Length];
            DataFieldMapping [] fields = new DataFieldMapping [keyPairs.Length];
            for (int i = 0; i < this.keyPairs.Length; i++)
            {
                DataFieldMapping field = mapping.FindDataEntityField(keyPairs [i].RelateKey);
                if (field == null)
                {
                    throw new LightDataException(string.Format(SR.CanNotFindTheSpecifiedField, mapping.ObjectType, keyPairs[i].RelateKey));
                }
                fields [i] = field;
                infos [i]  = new DataFieldInfo(field);
            }
            this.relateInfos         = infos;
            this.relateFieldMappings = fields;
            this.relateEntityMapping = mapping;
        }
Example #10
0
 protected QueryBase(DataContext dataContext)
 {
     _context = dataContext;
     _mapping = DataEntityMapping.GetEntityMapping(typeof(T));
 }
Example #11
0
 public override IAggregate <K> OrderByRandom()
 {
     _order = new RandomOrderExpression(DataEntityMapping.GetEntityMapping(typeof(T)));
     return(this);
 }
Example #12
0
 protected SelectBase(DataContext context, LambdaExpression expression, Type type)
 {
     _context    = context;
     _expression = expression;
     Mapping     = DataEntityMapping.GetEntityMapping(type);
 }
Example #13
0
 internal DataFieldInfo(Type type, string name)
     : this(DataEntityMapping.GetEntityMapping(type), false, name)
 {
 }