pechkin: (Default)
pechkin ([personal profile] pechkin) wrote2012-05-02 03:47 pm
Entry tags:

(no subject)

По-моему, это очень сильное колдунство - заменить 

StringBuilder sb = new StringBuilder("{");
foreach (var company in AvailableCompanies)
{
       sb.AppendFormat("\"{0}\":[{1}],", company.CompanyGUID, 
              string.Join(",", 
              AvailableCalls.Where(call => call.CompanyGUID.Equals(company.CompanyGUID)).ToArray()
              .Select(c=>string.Format("\"{0}\"", c.CallGUID))));
}
sb.Remove(sb.Length - 1, 1);
sb.Append("}");
return sb.ToString();

на

return Memo.User.Calls.GroupBy(call => call.CompanyGUID)
     .ToDictionary(group => group.Key.Value.ToString(),
          group => new JsonArray(group.Select(call => new JsonPrimitive(call.CallGUID.ToString()))))
     .AsEnumerable()
     .ToString();

[identity profile] cema.livejournal.com 2012-05-02 01:30 pm (UTC)(link)
А там .AsEnumerable() или .ToList() ?

[identity profile] pechkin.livejournal.com 2012-05-02 05:41 pm (UTC)(link)
AsEnumerable достаточно вполне.