Ejemplo n.º 1
0
        private static void Bind(object data, IDataRecord row, DbRecordInfo info)
        {
            var identityRecordInfo = info as DbIdentityRecordInfo;

            if (identityRecordInfo != null)
            {
                DbFieldInfo field = identityRecordInfo.PrimaryKey;

                object value = row[field.Name];
                if (value == DBNull.Value)
                {
                    if (field.DefaultValue != null)
                    {
                        value = field.DefaultValue;
                    }
                }
                else
                {
                    value = DbConverter.GetValue(field, value);
                }

                setValue(field, data, value);
            }

            int count = info.Fields.Length;

            for (int j = 0; j < count; j++)
            {
                DbFieldInfo field = info.Fields[j];
                object      value = row[field.Name];
                if (value == DBNull.Value)
                {
                    if (field.DefaultValue != null)
                    {
                        value = field.DefaultValue;
                    }
                }
                else
                {
                    value = DbConverter.GetValue(field, value);
                }

                setValue(field, data, value);

//                i++;
            }
        }