Skip to content

Instantly share code, notes, and snippets.

@mstarkman
Created August 10, 2011 19:33
Show Gist options
  • Save mstarkman/1137911 to your computer and use it in GitHub Desktop.
Save mstarkman/1137911 to your computer and use it in GitHub Desktop.
Social_GetNotificationCounts
using System;
using System.Linq;
using System.Collections.Generic;
using Fishidy.Domain.SqlServerStructures.Models.Persistence;
using Fishidy.Domain.SqlServerStructures.Models.Processing;
namespace Fishidy.Domain.SqlServerStructures.StoredProcedures
{
public class Social_GetNotificationCounts
{
public static List<Social_GetNotificationCountsResult> Execute(Guid? sourceNodeID)
{
var results = new List<Social_GetNotificationCountsResult>();
var notifications = FishidySqlMongo<NotificationTable>.AsQueryable.Where(n => n.TargetNodeID == sourceNodeID).ToList();
notifications
.GroupBy(n => n.RelationshipType, n => 1)
.ToList()
.ForEach(n => results.Add(new Social_GetNotificationCountsResult
{
RelationshipType = n.Key,
count = n.Sum()
}));
return results;
}
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment