Example #1
0
        public static IDictionary <DateTime, int> CommentsByPostSingle(int postId, DateTime min, DateTime max)
        {
            DataProvider dp  = DataService.Provider;
            QueryCommand cmd = new QueryCommand(@"
                select " +
                                                dp.SqlYearFunction("c.Published") + " as dvYear, " +
                                                dp.SqlMonthFunction("c.Published") + " as dvMonth, " +
                                                dp.SqlDayFunction("c.Published") + " as dvDay, " +
                                                dp.SqlCountFunction("c.Id") + @" as IdCount
                from
                    graffiti_Comments AS c
                where
                    c.Published >= " + dp.SqlVariable("MinDate") + @" and c.Published < " + dp.SqlVariable("MaxDate") + @"
	                and c.PostId = "     + dp.SqlVariable("PostId") + @"
                    and c.IsDeleted = 0
                group by " +
                                                dp.SqlYearFunction("c.Published") + ", " +
                                                dp.SqlMonthFunction("c.Published") + ", " +
                                                dp.SqlDayFunction("c.Published")
                                                );

            List <Parameter> parameters = Comment.GenerateParameters();
            Parameter        pPublished = Comment.FindParameter(parameters, "Published");

            cmd.Parameters.Add("MinDate", min, pPublished.DbType);
            cmd.Parameters.Add("MaxDate", max.AddDays(1), pPublished.DbType);
            cmd.Parameters.Add(Comment.FindParameter(parameters, "PostId")).Value = postId;

            return(GetDateDictionary(cmd));
        }
Example #2
0
        public static int CommentsByPostSingleCount(int postId, DateTime min, DateTime max)
        {
            DataProvider dp  = DataService.Provider;
            QueryCommand cmd = new QueryCommand(@"
                select
                    " + dp.SqlCountFunction("c.Id") + @" as IdCount
                from
                    graffiti_Comments c
                inner join
                    graffiti_Posts p on p.Id = c.PostId
                where
                    c.Published >= " + dp.SqlVariable("MinDate") + @" and c.Published < " + dp.SqlVariable("MaxDate") +
                                                @" and c.PostId = " + dp.SqlVariable("PostId") + @"
                    and c.IsDeleted = 0"
                                                );

            var       parameters = Comment.GenerateParameters();
            Parameter pPublished = Comment.FindParameter(parameters, "Published");

            cmd.Parameters.Add("MinDate", min, pPublished.DbType);
            cmd.Parameters.Add("MaxDate", max.AddDays(1), pPublished.DbType);
            cmd.Parameters.Add(Comment.FindParameter(parameters, "PostId")).Value = postId;

            return((int)DataService.ExecuteScalar(cmd));
        }