public static String ToId(this IPaged paged) { var properties = paged.GetType() .GetProperties(BindingFlags.Instance | BindingFlags.Public) .Select(x => { var val = x.GetValue(paged); if (val == null) { return(null); } return(x.Name + ":" + val.ToString()); }).Where(x => x != null); if (properties.Count() == 0) { return(""); } return(properties.Aggregate((cur, next) => $"{cur};{next}")); }
public static string ToId(this IPaged paged) { if (paged == null) { return("{}"); } var properties = paged.GetType() .GetProperties(BindingFlags.Instance | BindingFlags.Public) .Select(x => { var val = x.GetValue(paged); if (val == null) { return(x.Name + ":"); } return(x.Name + ":" + val.ToString()); }); var id = properties.Aggregate((cur, next) => $"{cur};{next}"); return($"{{{id}}}"); }