public PredicateRootPathResolver(IPredicate predicate, ITargetDataStore targetDataStore, ISourceDataStore sourceDataStore, ILogger logger)
		{
			_predicate = predicate;
			_targetDataStore = targetDataStore;
			_sourceDataStore = sourceDataStore;
			_logger = logger;
		}
Exemple #2
0
		/// <summary>
		/// Populates the Variable predicates of a target Atom, using another Atom as a template
		/// and a Fact as the source of data, i.e. Individual predicates.
		/// </summary>
		/// <param name="data">The data for populating the Atom.</param>
		/// <param name="template">The template of Atom being populated.</param>
		/// <param name="target">The members to populate.</param>
		public static void Populate(Fact data, Atom template, IPredicate[] members) {
			for(int i=0;i<members.Length;i++)
				if (members[i] is Variable) {
					int j = Array.IndexOf(template.Members, members[i]);
					if (j >= 0) members[i] = data.Members[j];
				}
		}
 public ConfigurationDetails(IPredicate predicate, ISerializationProvider serializationProvider, ISourceDataProvider sourceDataProvider, IEvaluator evaluator)
 {
     _predicate = predicate;
     _serializationProvider = serializationProvider;
     _sourceDataProvider = sourceDataProvider;
     _evaluator = evaluator;
 }
		// TODO

		private UnicornDataProvider CreateTestProvider(Database db, ITargetDataStore targetDataStore = null, ISourceDataStore sourceDataStore = null, IPredicate predicate = null, IFieldFilter filter = null, IUnicornDataProviderLogger logger = null, bool enableTransparentSync = false)
		{
			if (predicate == null)
			{
				predicate = CreateInclusiveTestPredicate();
			}

			if (filter == null)
			{
				filter = Substitute.For<IFieldFilter>();
				filter.Includes(Arg.Any<Guid>()).Returns(true);
			}

			targetDataStore = targetDataStore ?? Substitute.For<ITargetDataStore>();
			sourceDataStore = sourceDataStore ?? Substitute.For<ISourceDataStore>();

			var dp = new UnicornDataProvider(targetDataStore, 
				sourceDataStore, 
				predicate, 
				filter, 
				logger ?? Substitute.For<IUnicornDataProviderLogger>(), 
				new DefaultUnicornDataProviderConfiguration(enableTransparentSync), 
				new PredicateRootPathResolver(predicate, targetDataStore, sourceDataStore, Substitute.For<ILogger>()));
			
			dp.ParentDataProvider = db.GetDataProviders().First();

			return dp;
		}
        public FiatSitecoreSerializationProvider(IPredicate predicate, IFieldPredicate fieldPredicate, IFiatDeserializerLogger logger, string rootPath = null, string logName = "UnicornItemSerialization")
            : base(predicate, rootPath, logName)
        {
            Assert.ArgumentNotNull(logger, "logger");

            _deserializer = new FiatDeserializer(logger, fieldPredicate);
        }
        public TaskListWidgetModel()
        {
            Task[] tasks = TaskStorage.LoadTasks();

            _tasks = new TaskCollection(tasks);
            _selectedFilter = filters[0];
        }
        public PredicateFilteredItemData(IItemData innerItem, IPredicate predicate)
            : base(innerItem)
        {
            Assert.ArgumentNotNull(predicate, "predicate");

            _predicate = predicate;
        }
 public ConfigurationDetails(IPredicate predicate, ITargetDataStore serializationStore, ISourceDataStore sourceDataStore, IEvaluator evaluator)
 {
     _predicate = predicate;
     _serializationStore = serializationStore;
     _sourceDataStore = sourceDataStore;
     _evaluator = evaluator;
 }
		public FiatRemotedSerializationProvider(IPredicate predicate, IFieldPredicate fieldPredicate, IFiatDeserializerLogger logger, string remoteUrl = null, string rootPath = null, string logName = "UnicornItemSerialization")
			: base(predicate, fieldPredicate, logger, rootPath, logName)
		{
			Assert.ArgumentNotNull(remoteUrl, "remoteUrl");

			RemoteUrl = remoteUrl;
		}
Exemple #10
0
 /// <summary>
 /// Private constructor used for cloning.
 /// </summary>
 /// <param name="source">The source AtomFunction to use for building the new one.</param>
 /// <param name="members">The members to use in the new AtomFunction.</param>
 private AtomFunction(AtomFunction source, IPredicate[] members)
     : base(source, members)
 {
     this.bob = source.bob;
     this.functionSignature = source.functionSignature;
     this.resolutionType = source.resolutionType;
 }
        public string SelectSet(IClassMapper classMap, IPredicate predicate, IList<ISort> sort, int firstResult, int maxResults, IDictionary<string, object> parameters)
        {
            if (sort == null || !sort.Any())
            {
                throw new ArgumentNullException("Sort", "Sort cannot be null or empty.");
            }

            if (parameters == null)
            {
                throw new ArgumentNullException("Parameters");
            }

            StringBuilder innerSql = new StringBuilder(string.Format("SELECT {0} FROM {1}",
                BuildSelectColumns(classMap),
                GetTableName(classMap)));
            if (predicate != null)
            {
                innerSql.Append(" WHERE ")
                    .Append(predicate.GetSql(this, parameters));
            }

            string orderBy = sort.Select(s => GetColumnName(classMap, s.PropertyName, false) + (s.Ascending ? " ASC" : " DESC")).AppendStrings();
            innerSql.Append(" ORDER BY " + orderBy);

            string sql = Configuration.Dialect.GetSetSql(innerSql.ToString(), firstResult, maxResults, parameters);
            return sql;
        }
 public PredicateRootPathResolver(IPredicate predicate, ISerializationProvider serializationProvider, ISourceDataProvider sourceDataProvider, ILogger logger)
 {
     _predicate = predicate;
     _serializationProvider = serializationProvider;
     _sourceDataProvider = sourceDataProvider;
     _logger = logger;
 }
        public UnicornDataProvider(ITargetDataStore targetDataStore, ISourceDataStore sourceDataStore, IPredicate predicate, IFieldFilter fieldFilter, IUnicornDataProviderLogger logger, IUnicornDataProviderConfiguration dataProviderConfiguration, ISyncConfiguration syncConfiguration, PredicateRootPathResolver rootPathResolver)
        {
            Assert.ArgumentNotNull(targetDataStore, nameof(targetDataStore));
            Assert.ArgumentNotNull(predicate, nameof(predicate));
            Assert.ArgumentNotNull(fieldFilter, nameof(fieldFilter));
            Assert.ArgumentNotNull(logger, nameof(logger));
            Assert.ArgumentNotNull(sourceDataStore, nameof(sourceDataStore));
            Assert.ArgumentNotNull(dataProviderConfiguration, nameof(dataProviderConfiguration));
            Assert.ArgumentNotNull(rootPathResolver, nameof(rootPathResolver));
            Assert.ArgumentNotNull(syncConfiguration, nameof(syncConfiguration));

            _logger = logger;
            _dataProviderConfiguration = dataProviderConfiguration;
            _syncConfiguration = syncConfiguration;
            _rootPathResolver = rootPathResolver;
            _predicate = predicate;
            _fieldFilter = fieldFilter;
            _targetDataStore = targetDataStore;
            _sourceDataStore = sourceDataStore;

            // enable capturing recycle bin and archive restores to serialize the target item if included
            EventManager.Subscribe<RestoreItemCompletedEvent>(HandleItemRestored);

            try
            {
                _targetDataStore.RegisterForChanges(RemoveItemFromCaches);
            }
            catch (NotImplementedException)
            {
                // if the data store doesn't implement watching, cool story bruv
            }
        }
        public UnicornDataProvider(ITargetDataStore targetDataStore, ISourceDataStore sourceDataStore, IPredicate predicate, IFieldFilter fieldFilter, IUnicornDataProviderLogger logger, IUnicornDataProviderConfiguration configuration)
        {
            Assert.ArgumentNotNull(targetDataStore, "serializationProvider");
            Assert.ArgumentNotNull(predicate, "predicate");
            Assert.ArgumentNotNull(fieldFilter, "fieldPredicate");
            Assert.ArgumentNotNull(logger, "logger");
            Assert.ArgumentNotNull(sourceDataStore, "sourceDataStore");
            Assert.ArgumentNotNull(configuration, "configuration");

            _logger = logger;
            _configuration = configuration;
            _predicate = predicate;
            _fieldFilter = fieldFilter;
            _targetDataStore = targetDataStore;
            _sourceDataStore = sourceDataStore;

            try
            {
                _targetDataStore.RegisterForChanges(RemoveItemFromCaches);
            }
            catch (NotImplementedException)
            {
                // if the data store doesn't implement watching, cool story bruv
            }
        }
		public ConfigurationDetails(IPredicate predicate, ITargetDataStore serializationStore, ISourceDataStore sourceDataStore, IEvaluator evaluator, ConfigurationDependencyResolver dependencyResolver)
		{
			_predicate = predicate;
			_serializationStore = serializationStore;
			_sourceDataStore = sourceDataStore;
			_evaluator = evaluator;
			_dependencyResolver = dependencyResolver;
		}
Exemple #16
0
        /// <summary>
        /// Instantiates a new slot that will hold a named predicate.
        /// </summary>
        /// <param name="name">The name of the predicate</param>
        /// <param name="predicate">The predicate itself</param>
        public Slot(string name, IPredicate predicate)
        {
            if ((name == null) || (name == String.Empty)) throw new ArgumentException("The name of a slot can not be null or empty");
            if (predicate == null) throw new ArgumentException("The predicate of a slot can not be null");
            if (predicate is Slot) throw new ArgumentException("A slot can not contain another slot");

            this.name = name;
            this.predicate = predicate;
        }
Exemple #17
0
        internal Triple(ISubject s, IPredicate p, IObject o)
        {
            _s = s;
              _p = p;
              _o = o;

              _s.Value = CleanValue(_s.Value);
              _p.Value = CleanValue(_p.Value);
              _o.Value = CleanValue(_o.Value);
        }
 /// <summary>
 /// Creates a <see cref="ConditionalRule"/> with a 
 /// <see cref="IPredicate"/> instance and 
 /// <see cref="IRule"/> instance. If the predicate returns
 /// false, <paramref name="elseRule"/> is executed.
 /// </summary>
 /// <param name="predicate">
 /// <see cref="IPredicate"/> instance used for testing
 /// </param>
 /// <param name="rule">
 /// rule to execute.
 /// </param>
 /// <param name="elseRule">
 /// rule to execute if predicate is false.
 /// </param>
 /// <exception cref="ArgumentNullException">
 /// <paramref name="predicate"/> or <paramref name="rule"/>
 /// is a null reference.
 /// </exception>
 public ConditionalRule(IPredicate predicate, IRule rule, IRule elseRule)
     : base(false)
 {
     if (predicate==null)
         throw new ArgumentNullException("predicate");
     this.predicate=predicate;
     if (rule==null)
         throw new ArgumentNullException("rule");
     this.rule=rule;
     this.elseRule=elseRule;
 }
        public string Delete(IClassMapper classMap, IPredicate predicate, IDictionary<string, object> parameters)
        {
            StringBuilder sql = new StringBuilder(string.Format("DELETE FROM {0}", GetTableName(classMap)));
            if (predicate != null)
            {
                sql.Append(" WHERE ")
                    .Append(predicate.GetSql(parameters));
            }

            return sql.ToString();
        }
        public UnicornDataProvider(ISerializationProvider serializationProvider, IPredicate predicate, IFieldPredicate fieldPredicate, IUnicornDataProviderLogger logger)
        {
            Assert.ArgumentNotNull(serializationProvider, "serializationProvider");
            Assert.ArgumentNotNull(predicate, "predicate");
            Assert.ArgumentNotNull(fieldPredicate, "fieldPredicate");
            Assert.ArgumentNotNull(logger, "logger");

            _logger = logger;
            _predicate = predicate;
            _fieldPredicate = fieldPredicate;
            _serializationProvider = serializationProvider;
        }
Exemple #21
0
        /// <summary>
        /// 获取日消费清单
        /// </summary>
        /// <param name="start"></param>
        /// <param name="end"></param>
        /// <returns></returns>
        public IEnumerable<Daily> GetDailys(DateTime start, DateTime end)
        {
            IPredicate[] predicates = new IPredicate[]
            {
                Predicates.Field<Daily>(x => x.Date, Operator.Ge, start),
                Predicates.Field<Daily>(x => x.Date, Operator.Lt, new DateTime(end.Year, end.Month, end.Day).AddDays(1))
            };
            IList<ISort> sorts = new List<ISort>()
            {
                Predicates.Sort<Daily>(x => x.Date)
            };

            return _database.GetList<Daily>(Predicates.Group(GroupOperator.And, predicates), sorts);
        }
        public virtual string Delete(IClassMapper classMap, IPredicate predicate, IDictionary<string, object> parameters)
        {
            if (predicate == null)
            {
                throw new ArgumentNullException("Predicate");
            }

            if (parameters == null)
            {
                throw new ArgumentNullException("Parameters");
            }

            var sql = new StringBuilder(string.Format("DELETE FROM {0}", GetTableName(classMap)));
            sql.Append(" WHERE ").Append(predicate.GetSql(this, parameters));
            return sql.ToString();
        }
Exemple #23
0
 /* Fact Utils */
 /// <summary>
 /// Populates the Variable predicates of a target Atom, using another Atom as a template
 /// and a Fact as the source of data, i.e. Individual predicates.
 /// </summary>
 /// <param name="data">The data for populating the Atom.</param>
 /// <param name="template">The template of Atom being populated.</param>
 /// <param name="members">The members to populate.</param>
 internal static void Populate(Fact data, Atom template, IPredicate[] members)
 {
     for(int i=0;i<members.Length;i++)
         if (members[i] is Variable) {
             // try to locate a Variable with the same name in the template
             int j = Array.IndexOf(template.Members, members[i]);
             if (j >= 0) {
                 members[i] = data.Members[j];
             }
             else {
                 // try to locate a Slot with the same name in the template
                 j = Array.IndexOf(template.SlotNames, members[i].Value);
                 if (j >= 0) members[i] = data.Members[j];
             }
         }
 }
        public SerializationLoader(ITargetDataStore targetDataStore, ISourceDataStore sourceDataStore, IPredicate predicate, IEvaluator evaluator, ISerializationLoaderLogger logger, PredicateRootPathResolver predicateRootPathResolver)
        {
            Assert.ArgumentNotNull(targetDataStore, "serializationProvider");
            Assert.ArgumentNotNull(sourceDataStore, "sourceDataStore");
            Assert.ArgumentNotNull(predicate, "predicate");
            Assert.ArgumentNotNull(evaluator, "evaluator");
            Assert.ArgumentNotNull(logger, "logger");
            Assert.ArgumentNotNull(predicateRootPathResolver, "predicateRootPathResolver");

            Logger = logger;
            PredicateRootPathResolver = predicateRootPathResolver;
            Evaluator = evaluator;
            Predicate = predicate;
            TargetDataStore = targetDataStore;
            SourceDataStore = sourceDataStore;
        }
Exemple #25
0
        /// <summary>
        /// 获取日消费清单
        /// </summary>
        /// <param name="start"></param>
        /// <param name="end"></param>
        /// <returns></returns>
        public IEnumerable<Daily> GetDailys(DateTime start, DateTime end, int pageIndex, int pageSize, ref int count)
        {
            IPredicate[] predicates = new IPredicate[]
            {
                Predicates.Field<Daily>(x => x.Date, Operator.Ge, start),
                Predicates.Field<Daily>(x => x.Date, Operator.Lt, new DateTime(end.Year, end.Month, end.Day).AddDays(1))
            };
            IList<ISort> sorts = new List<ISort>()
            {
                Predicates.Sort<Daily>(x => x.Date),
                Predicates.Sort<Daily>(x => x.Cost)
            };

            count = _database.Count<Daily>(Predicates.Group(GroupOperator.And, predicates));
            return _database.GetPage<Daily>(Predicates.Group(GroupOperator.And, predicates), sorts, pageIndex - 1, pageSize);
        }
        public SerializationLoader(ISourceDataStore sourceDataStore, ITargetDataStore targetDataStore, IPredicate predicate, IEvaluator evaluator, ISerializationLoaderLogger logger, ISyncConfiguration syncConfiguration, PredicateRootPathResolver predicateRootPathResolver)
        {
            Assert.ArgumentNotNull(targetDataStore, nameof(targetDataStore));
            Assert.ArgumentNotNull(sourceDataStore, nameof(sourceDataStore));
            Assert.ArgumentNotNull(predicate, nameof(predicate));
            Assert.ArgumentNotNull(evaluator, nameof(evaluator));
            Assert.ArgumentNotNull(logger, nameof(logger));
            Assert.ArgumentNotNull(predicateRootPathResolver, nameof(predicateRootPathResolver));
            Assert.ArgumentNotNull(syncConfiguration, nameof(syncConfiguration));

            Logger = logger;
            SyncConfiguration = syncConfiguration;
            PredicateRootPathResolver = predicateRootPathResolver;
            Evaluator = evaluator;
            Predicate = predicate;
            TargetDataStore = targetDataStore;
            SourceDataStore = sourceDataStore;
        }
        public virtual string Count(IClassMapper classMap, IPredicate predicate, IDictionary<string, object> parameters)
        {
            if (parameters == null)
            {
                throw new ArgumentNullException("Parameters");
            }

            StringBuilder sql = new StringBuilder(string.Format("SELECT COUNT(*) AS {0}Total{1} FROM {2}",
                                Configuration.Dialect.OpenQuote,
                                Configuration.Dialect.CloseQuote,
                                GetTableName(classMap)));
            if (predicate != null)
            {
                sql.Append(" WHERE ")
                    .Append(predicate.GetSql(this, parameters));
            }

            return sql.ToString();
        }
        /// <summary>
        /// Default constructor
        /// </summary>
        /// <param name="rootPath">The root serialization path to write files to. Defaults to PathUtils.RootPath if the default value (null) is passed.</param>
        /// <param name="logName">The prefix to write log entries with. Useful if you have multiple serialization providers.</param>
        /// <param name="predicate">The predicate to use. If null, uses Registry to look up the registered DI instance.</param>
        public SitecoreSerializationProvider(IPredicate predicate, string rootPath = null, string logName = "UnicornItemSerialization")
        {
            rootPath = (rootPath == null || rootPath == "default") ? PathUtils.Root : rootPath;

            // allow root-relative serialization path (e.g. ~/data/serialization or ~/../data/serialization)
            rootPath = ConfigurationUtility.ResolveConfigurationPath(rootPath);

            Assert.ArgumentNotNullOrEmpty(rootPath, "rootPath");
            Assert.ArgumentNotNullOrEmpty(logName, "logName");
            Assert.ArgumentNotNull(predicate, "predicate");

            _predicate = predicate;

            // an unspoken expectation of the Sitecore path utils is that the serialization root is always post-fixed with the directory separator char
            // if this is not the case, custom path resolution can result in weird sitecore path mappings
            if (rootPath[rootPath.Length - 1] != Path.DirectorySeparatorChar)
                rootPath += Path.DirectorySeparatorChar;

            _rootPath = rootPath;
            _logName = logName;
        }
Exemple #29
0
		private AtomFunction(RelationResolutionType resolutionType,
		                    bool negative,
		                    IBinder bob,
		                    string type,
		                    IPredicate[] members,
		                    string functionSignature):base(negative, type, members) {
			
			if ((HasFunction) || (HasFormula))
				throw new BREException("Atom with function relation can not have a function or formula has a member: " + ToString());

			this.resolutionType = resolutionType;
			this.bob = bob;
			
			if (resolutionType == RelationResolutionType.Binder) {
				// precalculate the function signature to use in the binder to evaluate the function
				if (functionSignature == null)
					this.functionSignature = Parameter.BuildFunctionSignature(type, members);
				else
					this.functionSignature = functionSignature;
			}
		}
        public string Select(IClassMapper classMap, IPredicate predicate, IList<ISort> sort, IDictionary<string, object> parameters)
        {
            if (parameters == null)
            {
                throw new ArgumentNullException("Parameters");
            }

            StringBuilder sql = new StringBuilder(string.Format("SELECT {0} FROM {1}",
                BuildSelectColumns(classMap),
                GetTableName(classMap)));
            if (predicate != null)
            {
                sql.Append(" WHERE ")
                    .Append(predicate.GetSql(this, parameters));
            }

            if (sort != null && sort.Any())
            {
                sql.Append(" ORDER BY ")
                    .Append(sort.Select(s => GetColumnName(classMap, s.PropertyName, false) + (s.Ascending ? " ASC" : " DESC")).AppendStrings());
            }

            return sql.ToString();
        }
Exemple #31
0
 /// <summary>
 /// 删除单条记录
 /// </summary>
 /// <typeparam name="T"></typeparam>
 /// <param name="predicate"></param>
 /// <param name="transaction"></param>
 /// <returns></returns>
 public bool Delete <T>(IDbConnection conn, IPredicate predicate, IDbTransaction transaction = null) where T : class
 {
     return(conn.Delete <T>(predicate, transaction));
 }
Exemple #32
0
 /// <summary> Retrieves Entity rows in a datatable which match the specified filter. It will always create a new connection to the database.</summary>
 /// <param name="selectFilter">A predicate or predicate expression which should be used as filter for the entities to retrieve.</param>
 /// <param name="maxNumberOfItemsToReturn"> The maximum number of items to return with this retrieval query.</param>
 /// <param name="sortClauses">The order by specifications for the sorting of the resultset. When not specified, no sorting is applied.</param>
 /// <param name="relations">The set of relations to walk to construct to total query.</param>
 /// <returns>DataTable with the rows requested.</returns>
 public static DataTable GetMultiAsDataTable(IPredicate selectFilter, long maxNumberOfItemsToReturn, ISortExpression sortClauses, IRelationCollection relations)
 {
     return(GetMultiAsDataTable(selectFilter, maxNumberOfItemsToReturn, sortClauses, relations, 0, 0));
 }
Exemple #33
0
 /// <summary>Creates a new dynamic relation instance</summary>
 /// <param name="leftOperand">The left operand.</param>
 /// <param name="joinType">Type of the join. If None is specified, Inner is assumed.</param>
 /// <param name="rightOperand">The right operand.</param>
 /// <param name="onClause">The on clause for the join.</param>
 /// <returns>ready to use dynamic relation</returns>
 public override IDynamicRelation CreateDynamicRelation(DerivedTableDefinition leftOperand, JoinHint joinType, DerivedTableDefinition rightOperand, IPredicate onClause)
 {
     return(new DynamicRelation(leftOperand, joinType, rightOperand, onClause));
 }
Exemple #34
0
 /// <summary> Gets a scalar value, calculated with the aggregate and expression specified. the field index specified is the field the expression and aggregate are applied on.</summary>
 /// <param name="fieldIndex">Field index of field to which to apply the aggregate function and expression</param>
 /// <param name="expressionToExecute">The expression to execute. Can be null</param>
 /// <param name="aggregateToApply">Aggregate function to apply. </param>
 /// <param name="filter">The filter to apply to retrieve the scalar</param>
 /// <param name="groupByClause">The groupby clause to apply to retrieve the scalar</param>
 /// <returns>the scalar value requested</returns>
 public object GetScalar(GroupFieldIndex fieldIndex, IExpression expressionToExecute, AggregateFunction aggregateToApply, IPredicate filter, IGroupByCollection groupByClause)
 {
     return(GetScalar(fieldIndex, expressionToExecute, aggregateToApply, filter, null, groupByClause));
 }
Exemple #35
0
 /// <summary>Gets a scalar value, calculated with the aggregate and expression specified. the field index specified is the field the expression and aggregate are applied on.</summary>
 /// <param name="fieldIndex">Field index of field to which to apply the aggregate function and expression</param>
 /// <param name="expressionToExecute">The expression to execute. Can be null</param>
 /// <param name="aggregateToApply">Aggregate function to apply. </param>
 /// <param name="filter">The filter to apply to retrieve the scalar</param>
 /// <returns>the scalar value requested</returns>
 public object GetScalar(CategoryFieldIndex fieldIndex, IExpression expressionToExecute, AggregateFunction aggregateToApply, IPredicate filter)
 {
     return(GetScalar(fieldIndex, expressionToExecute, aggregateToApply, filter, null, null));
 }
Exemple #36
0
 /// <summary>Creates a new dynamic relation instance</summary>
 /// <param name="leftOperand">The left operand.</param>
 /// <param name="joinType">Type of the join. If None is specified, Inner is assumed.</param>
 /// <param name="rightOperand">The right operand.</param>
 /// <param name="aliasLeftOperand">The alias of the left operand. If you don't want to / need to alias the right operand (only alias if you have to), specify string.Empty.</param>
 /// <param name="onClause">The on clause for the join.</param>
 /// <returns>ready to use dynamic relation</returns>
 public override IDynamicRelation CreateDynamicRelation(IEntityFieldCore leftOperand, JoinHint joinType, DerivedTableDefinition rightOperand, string aliasLeftOperand, IPredicate onClause)
 {
     return(new DynamicRelation(leftOperand, joinType, rightOperand, aliasLeftOperand, onClause));
 }
Exemple #37
0
 /// <summary>Creates a new dynamic relation instance</summary>
 /// <param name="leftOperand">The left operand.</param>
 /// <param name="joinType">Type of the join. If None is specified, Inner is assumed.</param>
 /// <param name="rightOperandEntityName">Name of the entity, which is used as the right operand.</param>
 /// <param name="aliasLeftOperand">The alias of the left operand. If you don't want to / need to alias the right operand (only alias if you have to), specify string.Empty.</param>
 /// <param name="aliasRightOperand">The alias of the right operand. If you don't want to / need to alias the right operand (only alias if you have to), specify string.Empty.</param>
 /// <param name="onClause">The on clause for the join.</param>
 /// <returns>ready to use dynamic relation</returns>
 public override IDynamicRelation CreateDynamicRelation(IEntityFieldCore leftOperand, JoinHint joinType, string rightOperandEntityName, string aliasLeftOperand, string aliasRightOperand, IPredicate onClause)
 {
     return(new DynamicRelation(leftOperand, joinType, (NinjaSoftware.EnioNg.CoolJ.EntityType)Enum.Parse(typeof(NinjaSoftware.EnioNg.CoolJ.EntityType), rightOperandEntityName, false), aliasLeftOperand, aliasRightOperand, onClause));
 }
        /// <summary> Performs the update action of an existing Entity to the persistent storage.</summary>
        /// <param name="updateRestriction">Predicate expression, meant for concurrency checks in an Update query</param>
        /// <returns>true if succeeded, false otherwise</returns>
        protected override bool UpdateEntity(IPredicate updateRestriction)
        {
            ScrapReasonDAO dao = (ScrapReasonDAO)CreateDAOInstance();

            return(dao.UpdateExisting(base.Fields, base.Transaction, updateRestriction));
        }
Exemple #39
0
 /// <summary>
 /// Retrieves entities of the type 'RecycleVendorEntity' in a datatable which match the specified filter.
 /// It will always create a new connection to the database.
 /// </summary>
 /// <param name="maxNumberOfItemsToReturn"> The maximum number of items to return with this retrieval query.
 /// If the used Dynamic Query Engine supports it, 'TOP' is used to limit the amount of rows to return.
 /// When set to 0, no limitations are specified.</param>
 /// <param name="sortClauses">The order by specifications for the sorting of the resultset. When not specified, no sorting is applied.</param>
 /// <param name="selectFilter">A predicate or predicate expression which should be used as filter for the entities to retrieve.</param>
 /// <param name="relations">The set of relations to walk to construct to total query.</param>
 /// <param name="pageNumber">The page number to retrieve.</param>
 /// <param name="pageSize">The page size of the page to retrieve.</param>
 /// <returns>a filled datatable if succeeded, false otherwise</returns>
 public virtual DataTable GetMultiAsDataTable(long maxNumberOfItemsToReturn, ISortExpression sortClauses, IPredicate selectFilter, IRelationCollection relations, int pageNumber, int pageSize)
 {
     return(base.PerformGetMultiAsDataTableAction(maxNumberOfItemsToReturn, sortClauses, selectFilter, relations, pageNumber, pageSize));
 }
Exemple #40
0
        /// <summary> Gets a scalar value, calculated with the aggregate and expression specified. the field index specified is the field the expression and aggregate are applied on.</summary>
        /// <param name="fieldIndex">Field index of field to which to apply the aggregate function and expression</param>
        /// <param name="expressionToExecute">The expression to execute. Can be null</param>
        /// <param name="aggregateToApply">Aggregate function to apply. </param>
        /// <param name="filter">The filter to apply to retrieve the scalar</param>
        /// <param name="relations">The relations to walk</param>
        /// <param name="groupByClause">The groupby clause to apply to retrieve the scalar</param>
        /// <returns>the scalar value requested</returns>
        public virtual object GetScalar(CategoryFieldIndex fieldIndex, IExpression expressionToExecute, AggregateFunction aggregateToApply, IPredicate filter, IRelationCollection relations, IGroupByCollection groupByClause)
        {
            EntityFields fields = new EntityFields(1);

            fields[0] = EntityFieldFactory.Create(fieldIndex);
            if ((fields[0].ExpressionToApply == null) || (expressionToExecute != null))
            {
                fields[0].ExpressionToApply = expressionToExecute;
            }
            if ((fields[0].AggregateFunctionToApply == AggregateFunction.None) || (aggregateToApply != AggregateFunction.None))
            {
                fields[0].AggregateFunctionToApply = aggregateToApply;
            }
            return(DAOFactory.CreateCategoryDAO().GetScalar(fields, this.Transaction, filter, relations, groupByClause));
        }
Exemple #41
0
        /// <summary> Retrieves Entity rows in a datatable which match the specified filter. It will always create a new connection to the database.</summary>
        /// <param name="selectFilter">A predicate or predicate expression which should be used as filter for the entities to retrieve.</param>
        /// <param name="maxNumberOfItemsToReturn"> The maximum number of items to return with this retrieval query.</param>
        /// <param name="sortClauses">The order by specifications for the sorting of the resultset. When not specified, no sorting is applied.</param>
        /// <param name="relations">The set of relations to walk to construct to total query.</param>
        /// <param name="pageNumber">The page number to retrieve.</param>
        /// <param name="pageSize">The page size of the page to retrieve.</param>
        /// <returns>DataTable with the rows requested.</returns>
        public static DataTable GetMultiAsDataTable(IPredicate selectFilter, long maxNumberOfItemsToReturn, ISortExpression sortClauses, IRelationCollection relations, int pageNumber, int pageSize)
        {
            CategoryDAO dao = DAOFactory.CreateCategoryDAO();

            return(dao.GetMultiAsDataTable(maxNumberOfItemsToReturn, sortClauses, selectFilter, relations, pageNumber, pageSize));
        }
Exemple #42
0
 /// <summary>
 /// 查询列表数据
 /// </summary>
 /// <typeparam name="T"></typeparam>
 /// <param name="conn"></param>
 /// <param name="predicate"></param>
 /// <param name="sort"></param>
 /// <param name="trans"></param>
 /// <param name="buffered"></param>
 /// <returns></returns>
 public IEnumerable <T> GetList <T>(IDbConnection conn, IPredicate predicate = null, IList <ISort> sort = null, IDbTransaction trans = null,
                                    bool buffered = false) where T : class
 {
     return(conn.GetList <T>(predicate, sort, trans, null, buffered));
 }
Exemple #43
0
 /// <summary>
 /// 统计记录总数
 /// </summary>
 /// <typeparam name="T"></typeparam>
 /// <param name="predicate">条件</param>
 /// <param name="buffered">缓存</param>
 /// <returns></returns>
 public int Count <T>(IDbConnection conn, IPredicate predicate, bool buffered = false) where T : class
 {
     return(conn.Count <T>(predicate));
 }