FromMemberInfo() public static method

public static FromMemberInfo ( MemberInfo mi ) : ColumnInfo
mi System.Reflection.MemberInfo
return ColumnInfo
Example #1
0
        public PocoData(Type t, IMapper mapper, Cache <string, Type> aliasToTypeCache)
        {
            _mappingFactory = new MappingFactory(this);
            AliasToType     = aliasToTypeCache;
            type            = t;
            Mapper          = mapper;
            TableInfo       = TableInfo.FromPoco(t);

            // Call column mapper
            if (Mapper != null)
            {
                Mapper.GetTableInfo(t, TableInfo);
            }

            var alias = CreateAlias(type.Name, type);

            TableInfo.AutoAlias = alias;
            var index = 0;

            // Work out bound properties
            Columns = new Dictionary <string, PocoColumn>(StringComparer.OrdinalIgnoreCase);
            foreach (var mi in ReflectionUtils.GetFieldsAndPropertiesForClasses(t))
            {
                ColumnInfo ci = ColumnInfo.FromMemberInfo(mi);
                if (ci.IgnoreColumn)
                {
                    continue;
                }

                var pc = new PocoColumn();
                pc.TableInfo         = TableInfo;
                pc.MemberInfo        = mi;
                pc.ColumnName        = ci.ColumnName;
                pc.ResultColumn      = ci.ResultColumn;
                pc.ForceToUtc        = ci.ForceToUtc;
                pc.ComputedColumn    = ci.ComputedColumn;
                pc.ColumnType        = ci.ColumnType;
                pc.ColumnAlias       = ci.ColumnAlias;
                pc.VersionColumn     = ci.VersionColumn;
                pc.VersionColumnType = ci.VersionColumnType;

                if (Mapper != null && !Mapper.MapMemberToColumn(mi, ref pc.ColumnName, ref pc.ResultColumn))
                {
                    continue;
                }

                pc.AutoAlias = alias + "_" + index++;

                // Store it
                if (!Columns.ContainsKey(pc.ColumnName))
                {
                    Columns.Add(pc.ColumnName, pc);
                }
            }

            // Build column list for automatic select
            QueryColumns = Columns.Where(c => !c.Value.ResultColumn).ToArray();
        }
Example #2
0
        public PocoData(Type t, IMapper mapper)
        {
            type      = t;
            Mapper    = mapper;
            TableInfo = TableInfo.FromPoco(t);

            // Call column mapper
            if (Mapper != null)
            {
                Mapper.GetTableInfo(t, TableInfo);
            }

            // Work out bound properties
            Columns = new Dictionary <string, PocoColumn>(StringComparer.OrdinalIgnoreCase);
            foreach (var mi in ReflectionUtils.GetFieldsAndPropertiesForClasses(t))
            {
                ColumnInfo ci = ColumnInfo.FromMemberInfo(mi);
                if (ci == null)
                {
                    continue;
                }

                var pc = new PocoColumn();
                pc.MemberInfo   = mi;
                pc.ColumnName   = ci.ColumnName;
                pc.ResultColumn = ci.ResultColumn;
                pc.ForceToUtc   = ci.ForceToUtc;
                pc.ColumnType   = ci.ColumnType;

                if (Mapper != null && !Mapper.MapMemberToColumn(mi, ref pc.ColumnName, ref pc.ResultColumn))
                {
                    continue;
                }

                // Store it
                Columns.Add(pc.ColumnName, pc);
            }

            // Build column list for automatic select
            QueryColumns = Columns.Where(c => !c.Value.ResultColumn).Select(c => c.Key).ToArray();
        }
Example #3
0
 protected virtual ColumnInfo GetColumnInfo(MemberInfo mi, Type type)
 {
     return(ColumnInfo.FromMemberInfo(mi));
 }