5.0.5.1 新功能优化 无限树型条件 返回

SqlSugar 老数据
2 3287

无限树型过滤查询

Key表示操作方式 :And=0, Or=1 , Null=-1

[{
	"ConditionalList": [{
		"Key": -1,
		"Value": {
			"FieldName": "name",
			"FieldValue": "name",
			"ConditionalType": 0
		}
	}, {
		"Key": 0,
		"Value": {
			"ConditionalList": [{
				"Key": -1,
				"Value": {
					"FieldName": "customid",
					"FieldValue": "1",
					"ConditionalType": 0
				}
			}, {
				"Key": 1,
				"Value": {
					"FieldName": "id",
					"FieldValue": "1",
					"ConditionalType": 0
				}
			}, {
				"Key": 1,
				"Value": {
					"ConditionalList": [{
						"Key": -1,
						"Value": {
							"FieldName": "customid",
							"FieldValue": "1",
							"ConditionalType": 0
						}
					}]
				}
			}]
		}
	}, {
		"Key": 0,
		"Value": {
			"FieldName": "id",
			"FieldValue": "2",
			"ConditionalType": 0
		}
	}]
}]

生成SQL:

 WHERE  (   [name] = @Conditname10002  
     AND(   [customid] = @Conditcustomid10001   OR   [id] = @Conditid20001  OR(   [customid] = @Conditcustomid10000   )  )  
     AND   [id] = @Conditid30002   )


热忱回答2

  • fate sta fate sta VIP0
    2021/12/26
    [{
    	"ConditionalList": [{
    		"Key": -1,
    		"Value": {
    			"FieldName": "name",
    			"FieldValue": "name",
    			"ConditionalType": 0
    		}
    	}, {
    		"Key": 0,
    		"Value": {
    			"ConditionalList": [{
    				"Key": -1,
    				"Value": {
    					"FieldName": "customid",
    					"FieldValue": "1",
    					"ConditionalType": 0
    				}
    			}, {
    				"Key": 0,
    				"Value": {
    					"FieldName": "id",
    					"FieldValue": "1",
    					"ConditionalType": 0
    				}
    			}, {
    				"Key": 1,
    				"Value": {
    					"ConditionalList": [{
    						"Key": -1,
    						"Value": {
    							"FieldName": "customid",
    							"FieldValue": "1",
    							"ConditionalType": 0
    						}
    					}]
    				}
    			}]
    		}
    	}, {
    		"Key": 1,
    		"Value": {
    			"FieldName": "id",
    			"FieldValue": "2",
    			"ConditionalType": 0
    		}
    	}]
    }]
    WHERE  (   
           [name] = @Conditname10002  
    AND(   [customid] = @Conditcustomid10001   AND   [id] = @Conditid20001  OR(   [customid] = @Conditcustomid10000   )  )  
    
    OR   [id] = @Conditid30002   )

    Key表示操作方式 :And=0, Or=1 , Null=-1


    0 回复
  • fate sta fate sta VIP0
    2021/12/26
    var conModels= db.Context.Utilities.JsonToConditionalModels(json)  //JSO转成 List<IConditionalModel>
    var list = db.Queryable<Order>().Where(conModels).ToList();


    0 回复