Ejemplo n.º 1
0
 private void SetConditList(List <StorageableInfo <T> > itemList, List <EntityColumnInfo> whereColumns, List <IConditionalModel> conditList)
 {
     ;
     foreach (var dataItem in itemList)
     {
         var condition = new ConditionalCollections()
         {
             ConditionalList = new List <KeyValuePair <WhereType, SqlSugar.ConditionalModel> >()
         };
         conditList.Add(condition);
         int i = 0;
         foreach (var item in whereColumns)
         {
             var value = item.PropertyInfo.GetValue(dataItem.Item, null);
             if (value != null && value.GetType().IsEnum())
             {
                 if (this.Context.CurrentConnectionConfig.MoreSettings?.TableEnumIsString == true)
                 {
                     value = value.ToString();
                 }
                 else
                 {
                     value = Convert.ToInt64(value);
                 }
             }
             condition.ConditionalList.Add(new KeyValuePair <WhereType, ConditionalModel>(i == 0?WhereType.Or :WhereType.And, new ConditionalModel()
             {
                 FieldName             = item.DbColumnName,
                 ConditionalType       = ConditionalType.Equal,
                 CSharpTypeName        = UtilMethods.GetTypeName(value),
                 FieldValue            = value + "",
                 FieldValueConvertFunc = this.Context.CurrentConnectionConfig.DbType == DbType.PostgreSQL?
                                         UtilMethods.GetTypeConvert(value):null
             }));
             ++i;
         }
     }
 }