Ejemplo n.º 1
0
        public virtual string ResolveColumnName(PropertyInfo propertyInfo)
        {
            var columnName = DapperEasyCrud.Encapsulate(propertyInfo.Name);

            var columnattr = propertyInfo.GetCustomAttributes(true).SingleOrDefault(attr => attr.GetType().Name == typeof(ColumnAttribute).Name) as dynamic;

            if (columnattr != null)
            {
                columnName = DapperEasyCrud.Encapsulate(columnattr.Name);
                if (Debugger.IsAttached)
                {
                    Trace.WriteLine(String.Format("Column name for type overridden from {0} to {1}", propertyInfo.Name, columnName));
                }
            }
            return(columnName);
        }
Ejemplo n.º 2
0
        public virtual string ResolveTableName(Type type)
        {
            var tableName = DapperEasyCrud.Encapsulate(type.Name);

            var tableattr = type.GetCustomAttributes(true).SingleOrDefault(attr => attr.GetType().Name == typeof(TableAttribute).Name) as dynamic;

            if (tableattr != null)
            {
                tableName = DapperEasyCrud.Encapsulate(tableattr.Name);
                try
                {
                    if (!String.IsNullOrEmpty(tableattr.Schema))
                    {
                        string schemaName = DapperEasyCrud.Encapsulate(tableattr.Schema);
                        tableName = String.Format("{0}.{1}", schemaName, tableName);
                    }
                }
                catch (RuntimeBinderException)
                {
                    //Schema doesn't exist on this attribute.
                }
            }
            return(tableName);
        }