Defining a query gives different results

I wrote a definition query for the BranchTotal entity (built using the Entity Framework Designer). this object does not exist in my database.

I have created 3 scalar properties called



My defining query

<EntitySet Name="BranchTotals" EntityType="CarRentalModelModel.Store.BranchTotal">
        Select r.BranchID,
        count(r.reservationid) as TotalReservations,
        sum(p.AmountTotal) as TotalAmount
        from reservations r
        join payments p on r.reservationid = p.paymentid
        group by r.branchid


I wrote an example application where I get the result. When I did the same in my main application, I get the error

Provider does not support decimal to System.Int32 conversion


CarRentalModelEntities context = new CarRentalModelEntities();

var bTotals = context.BranchTotals;
foreach (var bTotal in bTotals)
    --Some code here--


Please help me what mistake I made.


source to share

All Articles