Ejemplo n.º 1
0
        /// <summary>
        /// Using a config filtered database object,  this will search for all entities that match a certain criteria in the database table.
        /// </summary>
        /// <returns>An altered copy of the database</returns>
        /// <param name="_database">Database.</param>
        /// <param name="schemaObjectNameSearchParm">Search parm that can be used to find a list of entities</param>
        public static List <IEntity> FindEntities(this IDatabase database, string schemaObjectNameSearchParm)
        {
            var listOfMatchedEntites = new List <IEntity>();
            var isMatch = false;

            //Use config settings to
            foreach (var entity in database.Entities.Values)
            {
                if (entity.Name.ToLower().Contains("tempload"))
                {
                    entity.Name += "";
                }
                var entitySchemaObjectName = new SchemaObjectName(entity);
                if (schemaObjectNameSearchParm.Contains(@"*")) //contains wildcard?
                {
                    isMatch = Regex.IsMatch(entitySchemaObjectName.AsFullName().ToLower(), "^" + Regex.Escape(schemaObjectNameSearchParm.ToLower()).Replace("\\?", ".").Replace("\\*", ".*") + "$");
                }
                else
                {
                    isMatch = (entitySchemaObjectName.AsFullName().ToLower().Equals(schemaObjectNameSearchParm.ToLower()));
                }
                if (isMatch)
                {
                    listOfMatchedEntites.Add(entity);
                }
            }
            return(listOfMatchedEntites);
        }
Ejemplo n.º 2
0
        /// <summary>
        /// Using a config filtered database object,  this will search for an entity in the database table.
        /// </summary>
        /// <returns>An altered copy of the database</returns>
        /// <param name="_database">Database.</param>
        /// <param name="config"></param>
        public static IEntity FindEntity(this IDatabase database, string _schemaObjectName)
        {
            var schemaObjectName = new SchemaObjectName(_schemaObjectName);

            //Use config settings to
            foreach (var entity in database.Entities.Values)
            {
                if ((entity.Schema.ToLower() == schemaObjectName.SchemaName.ToLower()) &&
                    (entity.Name.ToLower() == schemaObjectName.TableName.ToLower()))
                {
                    return(entity);
                }
            }
            return(null);
        }