예제 #1
0
        /// <summary>
        ///
        /// </summary>
        /// <param name="queryAction"></param>
        /// <returns></returns>
        public IgnoreChildPropertyDescriptors GetDescriptorsByQueryAction(DbQueryActions queryAction)
        {
            var _ignoreChildProperties = this.Where(prop => prop.QueryAction.HasFlag(queryAction))
                                         .Select(prop => new IgnoreChildPropertyDescriptor(prop, queryAction));

            return(new IgnoreChildPropertyDescriptors(_ignoreChildProperties, DeclaringDescriptor));
        }
        /// <summary>
        ///
        /// </summary>
        /// <param name="queryAction"></param>
        /// <param name="ignorePropertyDescriptors"></param>
        /// <returns></returns>
        public DbQueryPropertyDescriptors GetDescriptors(DbQueryActions queryAction, IgnoreChildPropertyDescriptors ignorePropertyDescriptors)
        {
            var _filteredProperties = GetDescriptorsByQueryAction(queryAction);

            if (!ignorePropertyDescriptors.IsEmpty)
            {
                var _propertyCollection = new ListCollection <DbQueryPropertyDescriptor>();

                foreach (var _filteredProperty in _filteredProperties)
                {
                    var _ignoreDescriptor = ignorePropertyDescriptors.GetDescriptor(_filteredProperty);

                    if (null != _ignoreDescriptor)
                    {
                        if (!_filteredProperty.PropertyDirection.Equals(DbQueryPropertyDirections.None))
                        {
                            var _propertyDirection = _filteredProperty.PropertyDirection & ~_ignoreDescriptor.PropertyDirection;

                            if (!((int)_propertyDirection).Equals(0))
                            {
                                _propertyCollection.Add(new DbQueryPropertyDescriptor(_filteredProperty, _propertyDirection));
                            }
                        }

                        continue;
                    }

                    _propertyCollection.Add(_filteredProperty);
                }

                return(new DbQueryPropertyDescriptors(_propertyCollection, _declaringDescriptor));
            }

            return(_filteredProperties);
        }
        /// <summary>
        ///
        /// </summary>
        /// <param name="queryAction"></param>
        /// <param name="ignorePropertyDescriptors"></param>
        /// <returns></returns>
        public DbQueryPropertyDescriptors GetDescriptorsByQueryAction(DbQueryActions queryAction)
        {
            var _descriptors = this.Where(prop => prop.ActionDescriptors.IsDeclared(queryAction))
                               .Select(prop => new DbQueryPropertyDescriptor(prop, queryAction));

            return(new DbQueryPropertyDescriptors(_descriptors, DeclaringDescriptor));
        }
예제 #4
0
        /// <summary>
        ///
        /// </summary>
        /// <param name="queryText"></param>
        /// <param name="queryAction"></param>
        /// <param name="queryBehavior"></param>
        /// <param name="name"></param>
        /// <param name="schema"></param>
        /// <param name="abbreviation"></param>
        internal DbQueryContract(string queryText, DbQueryActions queryAction, DbQueryBehaviors queryBehavior, string name, string schema, string abbreviation)
        {
            _queryText     = queryText;
            _queryAction   = queryAction;
            _queryBehavior = queryBehavior;

            _name         = name;
            _schema       = schema;
            _abbreviation = abbreviation;
        }
        /// <summary>
        ///
        /// </summary>
        /// <param name="attributeDescriptor"></param>
        /// <param name="queryAction"></param>
        internal IgnoreChildPropertyDescriptor(IgnoreChildPropertyDescriptor ignorePropertyDescriptor, DbQueryActions queryAction)
            : base(ignorePropertyDescriptor.Member)
        {
            _declaringDescriptor    = ignorePropertyDescriptor._declaringDescriptor;
            _declaringQueryProperty = ignorePropertyDescriptor._declaringQueryProperty;

            _ignoreChildProperty = ignorePropertyDescriptor._ignoreChildProperty;

            _queryAction       = queryAction;
            _propertyName      = ignorePropertyDescriptor._propertyName;
            _propertyDirection = ignorePropertyDescriptor._propertyDirection;
        }
예제 #6
0
        /// <summary>
        ///
        /// </summary>
        /// <typeparam name="TEntity"></typeparam>
        /// <param name="entity"></param>
        /// <param name="queryAction"></param>
        /// <param name="serviceContract"></param>
        /// <param name="queryContract"></param>
        /// <returns></returns>
        protected OperationResult <TEntity> ExecuteQuery <TEntity>(TEntity entity, DbQueryActions queryAction, IDataServiceContract serviceContract, IDbQueryContract queryContract)
            where TEntity : class
        {
            using (var _operationContext = new DbQueryOperationContext())
            {
                if (!IsExceptionalType(entity))
                {
                    var _memberDescriptor = _operationContext.DescriptorManager.GetDescriptor(entity);
                    var _serviceContract  = serviceContract ?? _memberDescriptor.ServiceContract;
                    var _operationSession = _operationContext.CreateSession(_serviceContract, queryAction);

                    _operationSession.Open();

                    ExecuteQueryImpl(_operationSession, entity, _memberDescriptor, _serviceContract, queryContract);

                    _operationSession.Close();
                }
                else
                {
                    var _entities = entity as IList;

                    for (var i = 0; i < _entities.Count; i++)
                    {
                        if (!_operationContext.HasErrors)
                        {
                            var _memberDescriptor = _operationContext.DescriptorManager.GetDescriptor(_entities[i]);
                            var _serviceContract  = serviceContract ?? _memberDescriptor.ServiceContract;
                            var _operationSession = _operationContext.CreateSession(_serviceContract, queryAction);

                            _operationSession.Open();

                            ExecuteQueryImpl(_operationSession, _entities[i], _memberDescriptor, _serviceContract, queryContract);

                            _operationSession.Close();

                            continue;
                        }

                        break;
                    }
                }

                if (_operationContext.HasErrors)
                {
                    return(new OperationResult <TEntity>(entity, _operationContext.Errors));
                }
            }

            return(new OperationResult <TEntity>(entity));
        }
        /// <summary>
        ///
        /// </summary>
        /// <param name="serviceContract"></param>
        /// <param name="queryAction"></param>
        /// <returns></returns>
        public DbQueryOperatingSession CreateSession(IDataServiceContract serviceContract, DbQueryActions queryAction)
        {
            var _connection       = _connectionPool.DetachConnection(serviceContract);
            var _operatingSession = new DbQueryOperatingSession(this, _connection, queryAction);

            _operatingSession.OperationFailed += new DbQueryFailedEventHandler(_OnOperationFailed);

            _innerSessionRepository.Add(_operatingSession);

            return(_operatingSession);
        }
 /// <summary>
 ///
 /// </summary>
 /// <param name="serviceContractProvider"></param>
 /// <param name="queryAction"></param>
 /// <returns></returns>
 public DbQueryOperatingSession CreateSession(IDataServiceContractProvider serviceContractProvider, DbQueryActions queryAction)
 {
     return(CreateSession(serviceContractProvider.ServiceContract, queryAction));
 }
예제 #9
0
 /// <summary>
 ///
 /// </summary>
 /// <param name="queryAction"></param>
 public DbQueryActionAttribute(DbQueryActions queryAction)
     : base()
 {
     QueryAction = queryAction;
 }
예제 #10
0
 /// <summary>
 ///
 /// </summary>
 /// <param name="action"></param>
 public DbQueryOperationAttribute(DbQueryActions action)
     : base()
 {
     QueryAction = action;
 }
 /// <summary>
 ///
 /// </summary>
 /// <param name="queryAction"></param>
 /// <returns></returns>
 public bool IsDeclared(DbQueryActions queryAction)
 {
     return(IsDeclared(x => x.QueryAction.HasFlag(queryAction)));
 }
 /// <summary>
 ///
 /// </summary>
 /// <param name="queryAction"></param>
 /// <returns></returns>
 public DbQueryOperationDescriptors GetDescriptorsByQueryAction(DbQueryActions queryAction)
 {
     return(GetDescriptorsByQueryOperation(x => x.QueryAction.HasFlag(queryAction)));
 }
예제 #13
0
 /// <summary>
 ///
 /// </summary>
 /// <param name="operationContext"></param>
 /// <param name="connection"></param>
 /// <param name="queryAction"></param>
 public DbQueryOperatingSession(DbQueryOperationContext operationContext, DbConnection connection, DbQueryActions queryAction)
     : base(operationContext)
 {
     _connection  = connection;
     _queryAction = queryAction;
 }
 /// <summary>
 ///
 /// </summary>
 /// <param name="queryAction"></param>
 /// <returns></returns>
 public DbQueryContractDescriptor GetDescriptorByAction(DbQueryActions queryAction)
 {
     return(GetDescriptorFor <IDbQueryContract>(x => x.QueryAction.Equals(queryAction)));
 }
예제 #15
0
 /// <summary>
 ///
 /// </summary>
 /// <param name="propertyName"></param>
 /// <param name="queryAction"></param>
 public IgnoreChildPropertyAttribute(string propertyName, DbQueryActions queryAction)
     : base()
 {
     _propertyName = propertyName;
     _queryAction  = queryAction;
 }
예제 #16
0
 /// <summary>
 ///
 /// </summary>
 /// <param name="queryAction"></param>
 /// <param name="queryText"></param>
 public DbQueryContractAttribute(DbQueryActions queryAction, string queryText)
     : base()
 {
     _queryAction = queryAction;
     _queryText   = queryText;
 }
예제 #17
0
 /// <summary>
 ///
 /// </summary>
 /// <param name="queryText"></param>
 /// <param name="queryAction"></param>
 /// <param name="queryBehavior"></param>
 /// <param name="name"></param>
 /// <param name="schema"></param>
 /// <param name="abbreviation"></param>
 /// <param name="omitsAbbreviationNaming"></param>
 internal DbQueryContract(string queryText, DbQueryActions queryAction, DbQueryBehaviors queryBehavior, string name, string schema, string abbreviation, bool omitsAbbreviationNaming)
     : this(queryText, queryAction, queryBehavior, name, schema, abbreviation)
 {
     _omitsAbbreviationNaming = omitsAbbreviationNaming;
 }
 /// <summary>
 ///
 /// </summary>
 /// <param name="queryAction"></param>
 /// <param name="propertyDirection"></param>
 /// <returns></returns>
 public DbQueryActionDescriptors GetDescriptors(DbQueryActions queryAction, DbQueryPropertyDirections propertyDirection)
 {
     return(GetDescriptorsByQueryAction(x => x.QueryAction.HasFlag(queryAction) && x.PropertyDirection.HasFlag(propertyDirection)));
 }