I chose not to use Linq.Dynamic, I discovered a way to verify conditions to dynamically add the keys to my GroupBy clause, the result is this:Dim lstGroupedFilter = (From t In lstDataSource Group t By __groupByKey1__ = _ New With {Key .Unit_ID = (If(blnUnit, t.Unit_ID, 0)), Key .Itinerary_ID = If(blnItinerary, t.Itinerary_ID, 0), Key .Driver_ID = If(blnDriver, t.Driver_ID, 0)} _ Into g = Group Select g.ToList()).ToList()这是一个动态添加键并生成类似于此解决方案.This is an option to dynamically add keys and generate a result similar to this solution. 这篇关于使用Linq使用动态键对数据进行分组的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持! 上岸,阿里云!