Exemplo n.º 1
0
 /// <summary>
 /// 设置指定索引位置的复杂属性值。
 /// </summary>
 /// <param name="source">设置对象。</param>
 /// <param name="index">属性相应的索引。</param>
 /// <param name="value">设置的值。</param>
 internal void SetComplexProperty(object source, int index, object value)
 {
     if (ClrType.IsAnonymous())
     {
         throw new InvalidOperationException(Res.ExceptionAnonymousObjectPropertyIsReadOnly);
     }
     if (SetComplexPropertyMethod == null)
     {
         SetComplexPropertyMethod = (Action <object, int, object>) new SetComplexPropertyGenerator(this).Compile();
     }
     SetComplexPropertyMethod(source, index, value);
 }
Exemplo n.º 2
0
 /// <summary>
 /// 根据属性索引列表加载指定的值到目标对象。
 /// </summary>
 /// <param name="data">数据内容。</param>
 /// <param name="indexs">赋值索引列表,按属性的排列顺序依次获取指定<see cref="DbDataReader"/>
 /// 索引处的值,若索引为 -1 则表示忽略该属性。</param>
 /// <param name="target">目标对象。</param>
 internal void ModifyProperty(object[] data, int[] indexs, object target)
 {
     if (ClrType.IsAnonymous())
     {
         throw new InvalidOperationException(Res.ExceptionAnonymousObjectPropertyIsReadOnly);
     }
     if (ModifyPrimaryProperty2Method == null)
     {
         ModifyPrimaryProperty2Method = (Action <object[], int[], object>) new ModifyPrimaryProperty2Generator(this).Compile();
     }
     ModifyPrimaryProperty2Method(data, indexs, target);
 }
Exemplo n.º 3
0
 /// <summary>
 /// 根据属性索引列表加载<see cref="DbDataReader"/>的数据到目标对象。
 /// </summary>
 /// <param name="reader">数据读取对象。</param>
 /// <param name="indexs">赋值索引列表,按属性的排列顺序依次获取指定<see cref="DbDataReader"/>
 /// 索引处的值,若索引为 -1 则表示忽略该属性。</param>
 /// <param name="target">目标对象。</param>
 public void ModifyProperty(DbDataReader reader, int[] indexs, object target)
 {
     if (ClrType.IsAnonymous())
     {
         throw new InvalidOperationException(Res.ExceptionAnonymousObjectPropertyIsReadOnly);
     }
     if (ModifyPrimaryPropertyMethod == null)
     {
         ModifyPrimaryPropertyMethod = (Action <DbDataReader, int[], object>) new ModifyPrimaryPropertyGenerator(this).Compile();
     }
     ModifyPrimaryPropertyMethod(reader, indexs, target);
 }
Exemplo n.º 4
0
 /// <summary>
 /// 使用<see cref="DbDataReader"/>中的数据创建当前类型实例。
 /// </summary>
 /// <param name="reader">数据读取器。</param>
 /// <param name="fields">字段索引列表。</param>
 /// <param name="complexs">读取值的暂存数组。</param>
 /// <returns></returns>
 internal object CreateInstance(DbDataReader reader, int[] fields, object[] complexs)
 {
     if (KeyIndexs != null && reader.IsDBNull(fields[KeyIndexs[0]]))
     {
         return(null);
     }
     if (CreateInstanceMethod == null)
     {
         if (ClrType.IsAnonymous())
         {
             CreateInstanceMethod = (Func <DbDataReader, int[], object[], object>) new CreateAnonymousInstanceGenerator(this).Compile();
         }
         else
         {
             CreateInstanceMethod = (Func <DbDataReader, int[], object[], object>) new CreateSimpleInstanceGenerator(this).Compile();
         }
     }
     return(CreateInstanceMethod(reader, fields, complexs));
 }