コード例 #1
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 pi in t.GetProperties())
            {
                ColumnInfo ci = ColumnInfo.FromProperty(pi);
                if (ci == null)
                {
                    continue;
                }

                var pc = new PocoColumn();
                pc.PropertyInfo = pi;
                pc.ColumnName   = ci.ColumnName;
                pc.ResultColumn = ci.ResultColumn;
                pc.ForceToUtc   = ci.ForceToUtc;
                pc.ColumnType   = ci.ColumnType;

                if (Mapper != null && !Mapper.MapPropertyToColumn(pi, 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();
        }