? orus casino? bodog? ruleta? luckia? betano? sportium? spin casino? stakes? 3 reyes? 888? lottoland? coolbet? 777 casino? gana777? betfair? bwin? yak casino? ivy casino? oddschecker? red casino? netbet? william hill? vip casino? rey casino? marathonbet? dafabet? sol casino? 1bet? winland? bet777? parimatch? 18bet? 888casino? campobet? mostbet? ganabet? rushbet? betcris? betsson? lucky? novibet? winner? winpot? betmaster? betmexico? cancun? playcity? strendus? pokerstars? codere? caliente? fun88? bbrbet? 1win? 10bet? betway? pin up? spinbet? 7cslot? pickwin? spin bet? mr fortune? w88? pragmatic? gamdom? crasher? jojobet? betmex? bcasino? foliatti? winner mx? bets 10? big bola? bet master? inbet? 7slots? lucky day? m777? mexplay? luckydays? bet caliente? 1x? plinko

Forum


HomeHomePremiumPremiumDevelopmentDevelopmentDAL2 - CountDAL2 - Count
Previous
 
Next
New Post
12/20/2013 7:22 AM
 

I want to get counts for various groupings of data in some of my tables and am not sure if it is possible using DAL2.

I want perform queries such as:

SELECT  DISTINCT productType, COUNT(*) FROM Products GROUP BY productType

The information I come across only includes examples that allow the user to specify the WHERE part of the SQL.  This example unfortunately skirts right around the WHERE part of the query so I am not sure how I should approach this using DAL2.  Is it possible using DAL2 and if so, how do I execute such a query?

 

Thanks

 
New Post
12/20/2013 10:14 AM
 

Andy,

My thought on this is...

Let's say you have a ProductType class which is your DAL2 model.  You create another class that is just a simple POCO.  

Example:

    public class ProductTypeSummary
    {
        public int ProductType { get; set; }
        public int ProductTypeCount { get; set; }
    }

Inside your ProductType DAL Repository class, you can add a method like:

     public IEnumerable<ProductTypeSummary> GetProductTypeSummary()
     {
            using (IDataContext ctx = DataContext.Instance())
            {
                return ctx.ExecuteQuery<ProductTypeSummary>(System.Data.CommandType.Text,
                    "SELECT ProductType, COUNT(*) AS ProductTypeCount FROM Products GROUP BY ProductType");
            }  

     }

I haven't tested this obviously, but I think it should work.

 
Previous
 
Next
HomeHomePremiumPremiumDevelopmentDevelopmentDAL2 - CountDAL2 - Count



Try FREE
30 days money back guaranteed