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); condition.ConditionalList.Add(new KeyValuePair <WhereType, ConditionalModel>(i == 0?WhereType.Or :WhereType.And, new ConditionalModel() { FieldName = item.DbColumnName, ConditionalType = ConditionalType.Equal, FieldValue = value + "", FieldValueConvertFunc = this.Context.CurrentConnectionConfig.DbType == DbType.PostgreSQL? UtilMethods.GetTypeConvert(value):null })); ++i; } } }
private void SetConditList(List <DataRow> itemList, string[] 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 name in whereColumns) { var value = dataItem[name]; if (value != null && value.GetType().IsEnum()) { value = Convert.ToInt64(value); } condition.ConditionalList.Add(new KeyValuePair <WhereType, ConditionalModel>(i == 0 ? WhereType.Or : WhereType.And, new ConditionalModel() { FieldName = name, ConditionalType = ConditionalType.Equal, FieldValue = value + "", FieldValueConvertFunc = this.Context.CurrentConnectionConfig.DbType == DbType.PostgreSQL ? UtilMethods.GetTypeConvert(value) : null })); ++i; } } }
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; } } }