public static DynamicObject[] AutoSetPrimaryKey(this IEnumerable <DynamicObject> dataObject, Context ctx) { DynamicObject[] dataArray = dataObject.ToArray(); if (dataArray.Any()) { var group = dataArray.Select(data => new { DataEntity = data, DataType = data.DynamicObjectType }) .GroupBy(a => a.DataType) .Select(g => new { DataType = g.Key, DataArray = g.Select(a => a.DataEntity).ToArray() }) .ToList(); group.ForEach(g => DBServiceHelper.AutoSetPrimaryKey(ctx, g.DataArray, g.DataType)); } //end if return(dataArray); } //end method