c# - Use Sql View in EF 6.0 -


i have cashflowview:

    create view [dbo].[cashflowview] cte ( select           row_number() on (order ratedate) id          , sum(case when c.currencyname = 'br' t.amountmoney else 0 end)  amountbyr          , sum(case when c.currencyname = 'usd' t.amountmoney else 0 end)  amountusd                   , cr.ratedate [date]     transactions t          inner join accounts on a.accountid = t.currentaccountid          inner join currencies c on c.currencyid = a.currencyid          right outer join currencyrates cr on cr.ratedate = t.executiondate group cr.ratedate ) select          id         , a.amountbyr         , (select sum(b.amountbyr) cte b b.id<=a.id) balancebyr         , a.amountusd         , (select sum(b.amountusd) cte b b.id<=a.id) balanceusd         , [date]   cte 

then i've added entity:

public class cashflowview     {         [key]         public int id { get; set; }         public decimal amountbyr { get; set; }         public decimal balancebyr { get; set; }         public decimal amountusd { get; set; }         public decimal balanceusd { get; set; }         public datetime date { get; set; }     } 

and, understand, need add code context:

public dbset<cashflowview> cashflowview { get; set; } 

and wanna use view:

 ilist<cashflowview> listview;             using (var _db = new economicappcontext())             {                 listview = _db.cashflowview.tolist();              } 

but listview empty. how may create correct mapping view (maybe using migration) , use it?

i did it. try combine article http://www.paragon-inc.com/resources/blogs-posts/a-certain-point-of-view-part-1-ef-code-first , use entity framework power tools find needed result. , check connection. i've got problems perfomance, use dispose method carefully.


Comments

Popular posts from this blog

google chrome - Developer tools - How to inspect the elements which are added momentarily (by JQuery)? -

angularjs - Showing an empty as first option in select tag -

php - Cloud9 cloud IDE and CakePHP -