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
BranchID(Int32), TotalReservations(Int32), TotalAmount(Decimal)
My defining query
<EntitySet Name="BranchTotals" EntityType="CarRentalModelModel.Store.BranchTotal">
<DefiningQuery>
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
</DefiningQuery>
</EntitySet>
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
Code:
CarRentalModelEntities context = new CarRentalModelEntities();
var bTotals = context.BranchTotals;
foreach (var bTotal in bTotals)
{
--Some code here--
}
Please help me what mistake I made.
+3
source to share
No one has answered this question yet
Check out similar questions: