asp.net-mvc


Can you map the results of a manual SQL query to objects in Entity Framework?


In LINQ, you can write a manual SQL query, take the results from it and have LINQ "map" those into the appropriate properties of your Model classes (or at least, I'm pretty sure I read you can do that).
Is it possible to do something like that in Entity Framework?
I have an web app that's using EF, and it's CPU usage is ridiculously high compared to the traffic it has, and profiling it in my machine, all that time is (predictably) spent in the DB functions, and the largest portion of that time (> 85%) is spent by EF "generating" SQL and doing stuff before actually executing a query.
So my reasoning is that I can just go in and hardcode the SQL queries, but still use my populated Model properties in my view.
Is this possible? If so, how would I do it?
Thanks!
Daniel
So what you want to do is hydrate an object from an IDataReader? It's pretty easy to write code to do this (hint: reflection! or you can get fancy and use a member initialization expression) or you can Google for myriad existing implementations on the Internet.
You can do this within EF using ObjectContext.ExecuteStoreQuery<T> or ObjectContext.Translate<T> if you already have a DbDataReader.

Related Links

Url delimiter with “-” MVC Routes
FoolProof MVC GreaterThan not working with time
Microsoft Word Online Edition in asp.net mvc web application
MVC Areas & Shared Layouts
automapper with pagedlist always return one page
Adding validation data attributes to custom input
Drop down toggle is not working in pagination
How can I destroy session in Asp.net MVC 5?
Include a sorted bundle to another bundle
ASP.NET MVC - The entity type IdentityRole is not part of the model for the current context
ASP.NET Bootstrap table padding between columns not working
MVC - ADFS Authentication - ADFS redirects to localhost
Error: “The resource cannot be found” when trying to pass in an empty object to View
MVC Model Navigation Property
why image is not loading to the view page in mvc razor
How to generate a custom image for facebook crawler?

Categories

HOME
html5-canvas
codenameone
android-activity
fonts
saml
entity
py.test
base
uwsgi
pymc3
cytoscape.js
message
lag
raspberry-pi2
syswow64
stackexchange-api
silk-performer
nsmutableattributedstring
h.264
gyroscope
exe4j
freetype
jscodeshift
jpos
semantics
urlrewriter.net
pvs-studio
unsigned-integer
jtable
number-formatting
parallax.js
whatsapi
subtotal
webcenter
jackrabbit
packaging
google-slides
jquery-ui-dialog
msysgit
ase
php-deployer
hydra
hostapd
ewsjavaapi
ms-jet-ace
adal.js
stroke
htc
master-data-management
dwr
playback
jawr
jvm-arguments
findall
cabal-install
android-alertdialog
bootstrap-slider
android-chips
balsamiq
activity-diagram
singly-linked-list
ios-frameworks
python-3.1
blpapi
mutation
schematiq
yapdatabase
illegalstateexception
egl
dbfit
python-dragonfly
xirr
openejb
hjson
ubiquity
crosswalk
viennacl
mailx
access-log
size-t
fastparse
vraptor
mks
misra
controlsfx
image-scaling
jqgrid-php
blueprint
ioerror
datadesign
double-precision
java-ee-5
ariatemplates
j#
proxy-classes
katta
ladon
datatemplate
replay
apache-config
seam-conversation
net-ssh
coords
palm-pre

Resources

Mobile Apps Dev
Database Users
javascript
java
csharp
php
android
MS Developer
developer works
python
ios
c
html
jquery
RDBMS discuss
Cloud Virtualization
Database Dev&Adm
javascript
java
csharp
php
python
android
jquery
ruby
ios
html
Mobile App
Mobile App
Mobile App