Click here to Skip to main content
15,888,113 members
Please Sign up or sign in to vote.
1.00/5 (2 votes)
See more:
I have two classes I need to make an ordered list from both of them fist order by highlighted then by created time


First Class

public class WebPost
{
public string id { get; set; }
public string page_id { get; set; }
public string page_name { get; set; }
public string message { get; set; }
public string picture { get; set; }
public string link { get; set; }
public string source { get; set; }
public string type { get; set; }
public string shares_count { get; set; }
public string likes_count { get; set; }
public string comments_count { get; set; }
public DateTime created_time { get; set; }
}



Second Class

public class WebResponse
{
public string feed_social_id { get; set; }
public string social_service_id { get; set; }
public string value { get; set; }
public bool highlighted { get; set; }
}
Posted
Comments
Denis Shemenko 8-Jul-13 0:03am    
What you Want??
m.esmail 8-Jul-13 0:19am    
I solved it thanks for you
Sadique KT 8-Jul-13 2:34am    
post ur solution...n mark as answered..

1 solution

ConcurrentDictionary<webresponse,>> parallelPostsDictionary = new ConcurrentDictionary<webresponse,>>();

List<webpost> highlitedlist = new List<webpost>();
List<webpost> normallist = new List<webpost>();

foreach (var key in parallelPostsDictionary.Keys)
{
List<webpost> result = null;

parallelPostsDictionary.TryGetValue(key, out result);
if (key.highlighted)
{
highlitedlist.Add(result.ElementAt(0));
result.RemoveAt(0);
}

normallist.AddRange(result);
}

highlitedlist = highlitedlist.OrderByDescending(x => x.created_time).ToList();
normallist = normallist.OrderByDescending(x => x.created_time).ToList();
fb_Posts.AddRange(highlitedlist);
fb_Posts.AddRange(normallist);

Cache.Add<list><webpost>>(cacheKey, fb_Posts, expiryTime);
C#

 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900