public T[] GetEntities <T>(Dictionary <string, object> arguments, QueryLogicalOperator logicalOperator = QueryLogicalOperator.None) where T : MetadataEntity, new()
        {
            var      entityType = typeof(T);
            List <T> results    = null;

            CreateDataDBAdapterForEntity <T>(entityType, context => results = context.Get <T>(entityType.Name, arguments, logicalOperator));
            return(results?.ToArray());
        }
Ejemplo n.º 2
0
        /// <summary>
        /// Gets the specified objects with the <c>tableName</c> and multi-conditions.
        /// </summary>
        /// <typeparam name="T">Specifies the object type of return.</typeparam>
        /// <param name="tableName">Name of the table.</param>
        /// <param name="arguments">The arguments.</param>
        /// <param name="logicalOperator">The logical operator.</param>
        /// <returns>The objects that was found.</returns>
        public List <T> Get <T>(string tableName, Dictionary <string, object> arguments, QueryLogicalOperator logicalOperator = QueryLogicalOperator.None) where T : class, new()
        {
            CheckIfDisposed();
            CheckIfDatabaseIsOpen();

            var builder = new StringBuilder();

            builder.AppendFormat("from {0} where ", tableName);

            var i = 0;

            foreach (var key in arguments.Keys)
            {
                builder.AppendFormat("{0} == ?", key);
                i++;

                if (i < arguments.Keys.Count)
                {
                    switch (logicalOperator)
                    {
                    case QueryLogicalOperator.And:
                    default:
                        builder.Append(" & ");
                        break;

                    case QueryLogicalOperator.Or:
                        builder.Append(" | ");
                        break;
                    }
                }
            }

            var args = new object[arguments.Count];

            arguments.Values.CopyTo(args, 0);
            return(Box.Select <T>(builder.ToString(), args));
        }
 public StorageLogicalExpression(StorageQueryOperand left, StorageQueryOperand right, QueryLogicalOperator operatorNode) : base(left, right)
 {
     Operator = operatorNode;
 }