LinQ多字段排序的误区,代码本身不报错,但是得不到应有的效果,此处列出了我测试的几个方法,只有第一个是对的
//正确 var weldtable = (from tt in database.NDEWeldingCheckData where tt.IsDelete == false && tt.FK_TasComID == jobnoid select tt ) .OrderBy(p => p.SpaType) .ThenBy(p => p.WeldingCheckTypeGoup) .ThenBy(p => p.OrderNumber); //错误 var weldtable = (from tt in database.NDEWeldingCheckData where tt.IsDelete == false && tt.FK_TasComID == jobnoid orderby tt.SpaType, tt.WeldingCheckTypeGoup, tt.OrderNumber select tt ); //错误 var weldtable = (from tt in database.NDEWeldingCheckData where tt.IsDelete == false && tt.FK_TasComID == jobnoid orderby tt.SpaType orderby tt.WeldingCheckTypeGoup orderby tt.OrderNumber select tt );