Exemplo n.º 1
0
 private void SetInsertItemByEntity(int i, T item, List <DbColumnInfo> insertItem)
 {
     if (item == null)
     {
         return;
     }
     foreach (var column in EntityInfo.Columns)
     {
         if (column.IsIgnore || column.IsOnlyIgnoreInsert)
         {
             continue;
         }
         var columnInfo = new DbColumnInfo()
         {
             Value        = column.PropertyInfo.GetValue(item, null),
             DbColumnName = GetDbColumnName(column.PropertyName),
             PropertyName = column.PropertyName,
             PropertyType = UtilMethods.GetUnderType(column.PropertyInfo),
             TableId      = i
         };
         if (columnInfo.PropertyType.IsEnum())
         {
             columnInfo.Value = Convert.ToInt64(columnInfo.Value);
         }
         if (column.IsJson && columnInfo.Value != null)
         {
             columnInfo.Value = this.Context.Utilities.SerializeObject(columnInfo.Value);
         }
         var tranColumn = EntityInfo.Columns.FirstOrDefault(it => it.IsTranscoding && it.DbColumnName.Equals(column.DbColumnName, StringComparison.CurrentCultureIgnoreCase));
         if (tranColumn != null && columnInfo.Value.HasValue())
         {
             columnInfo.Value = UtilMethods.EncodeBase64(columnInfo.Value.ToString());
         }
         insertItem.Add(columnInfo);
     }
 }