c# - Using an SQL View from an Entity Framework Code First version 5 -


i developing contact log in website using vs 2010, mvc3 , ef 5 - entities created using code first. data stored in sql server 2008 r2 set of databases. want display summary of contact log , have created view.

create view dbo.contactlogsummaries   select     cle.contactlogentryid,     cle.caseid,     'test' contactname,     eu.username officeuser,     cle.dateandtimeofcontact,     clc.category,     cle.contactdetails      contactlogentries cle     join     contactlogcategories clc     on cle.contactlogcategoryid = clc.contactlogcategoryid     join     control.dbo.endusers eu     on cle.userid = eu.enduserid 

there 2 entities in contact log database (contactlogentries , contactlogcategories) , database first entity control.dbo.endusers in database. contact log contain large number of records. want able display records specific case.

my question in 2 parts:

  1. can use sql view directly display summary on web page (perhaps reading class)
  2. can create code first object equivalent sql view.

you can map entity directly view using tableattribute (data annoations), or totable in fluent mappings...

for example using data annotions:

using system; using system.componentmodel.dataannotations; using system.componentmodel.dataannotations.schema;  public namespace whatever.mynamespace      [table("dbo.contactlogsummaries")] //<-- view     public class contactlogsummary     {         ...     } } 

Comments

Popular posts from this blog

html - How to style widget with post count different than without post count -

How to remove text and logo OR add Overflow on Android ActionBar using AppCompat on API 8? -

javascript - storing input from prompt in array and displaying the array -