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
c # entity-framework


source to share


No one has answered this question yet

Check out similar questions:

6155
What is the difference between string and string in C #?
1743
What's the best way to give a C # auto property an initial value?
1507
What is the difference between an abstract function and a virtual function?
1240
What is the difference between const and readonly in C #?
987
LINQ Query on DataTable
975
What is the difference between a field and a property?
975
Difference between Select and SelectMany
838
What's the difference between the "ref" and "out" keywords?
705
Calculate the difference between two dates (number of days)?
328
Entity cannot be built in LINQ to Entities query



All Articles
Loading...
X
Show
Funny
Dev
Pics