示例#1
0
 public override void OnReader(DatabaseReader reader)
 {
     if (reader == null)
     {
         Obj = default(T);
     }
     if (reader.ElementCount <= 0)
     {
         Obj = default(T);
     }
     foreach (var item in reader)
     {
         DatabaseReader.DatabaseElement oElement = item as DatabaseReader.DatabaseElement;
         for (int i = 0; i < reader.FieldCount; i++)
         {
             Container.SQLFields[i].Value = oElement.GetValue(i);
         }
         break;  // Search 限定只查询一个数据,因此这里执行一次后直接返回
     }
     FieldInfo[] fieldInfos = Obj.GetType().GetFields();
     for (int i = 0; i < fieldInfos.Length; i++)
     {
         FieldInfo   fieldInfo  = fieldInfos[i];
         DbFieldBase oBaseField = SearchField(Container.SQLFields, fieldInfo.Name);
         if (oBaseField != null)
         {
             try
             {
                 fieldInfo.SetValue(Obj, Convert.ChangeType(oBaseField.Value, fieldInfo.FieldType));
             }
             catch (Exception e)
             {
                 App.Error("设置参数出现异常! 表{0} 索引位置{1}, 列名{2} 异常:{3}", Container.SQLTable, i, oBaseField.FieldName, e);
             }
         }
     }
 }
示例#2
0
 public DatabaseReaderEnumerator(DatabaseReader databaseReader)
 {
     this.databaseReader = databaseReader;
 }
示例#3
0
 public virtual void OnReader(DatabaseReader reader)
 {
 }