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

ASP.NET MVC Upload file
Bootstrap 3 long modal open fix postion
Sitefinity 9.2 MVC 5 Feather and Ninject - Error loading module, another module with the same name has already been loaded
HTML Changes Not Being Shown in Build for Visual Studio 2017
Replace string in Razor View
MVC5 : Retrieving newly created record and repopulating the partial view with newly created record
MVC give error Assembly are not loaded
identify which button is being clicked in mvc 5
Whitelisted azure outbound ip addresses not connecting to smtp server
Asp.net MVC Token Based Autnetication and Authorization
Asp.Net MVC Helper: create a global helper for loading view with or without layout
Single Sign On - Asp.Net Identity not working
How to override Elmah applicationname set in Web.config
Not receiving claims from WSO2 Identity Server (v5.1.0) when used with Oauth2
Web api Jwt token implement Logout functionality using MVC.net as a front end
MVC controller, get a file from WebAPI and return as FileResult

Categories

HOME
elastic-beanstalk
vb.net
embedded-linux
ffmpeg
oozie
whatsapp
dynamics-crm-365
azure-search
module
jsessionid
runtime-error
feed
antlr4
intl
identifier
copy-paste
wso2ei
light-inject
development-environment
pouchdb
signature
reload
coreos
smartsheet-c#-sdk-v2
teraterm
servlet-filters
exe4j
swig
teamcity-9.0
co
deadbolt
aikau
ratchet-2
android-arrayadapter
ruamel.yaml
subtotal
argparse
increment
nio
bezier
solid-principles
cookiestore
brainfuck
google-slides
btle
edeliver
nscalendar
program-slicing
php-deployer
virtualmin
gretl
openwebanalytics
uservoice
stroke
node.js-tape
abbyy
asp.net-mvc-custom-filter
turbo-c
itamae
informatica-cloud
perspective
menustrip
rabbitvcs
okuma
training-data
occam-pi
xelement
fab
greenfoot
symbian
bonfire
bloodhound
getuikit
android-design-library
spiceworks
sqlhelper
httpservice
express-jwt
django-supervisor
delphi-2009
nawk
jquery-mobile-popup
emacs-jedi
hresult
xcode4.2
visual-assist
git-gui
geometry-surface
square-cube
cassette
timespan
mixing
calloc
noindex
nsinvocation
expressionvisitor
consistent-hashing
datatemplate
textboxlist
combinators
coords
gedcom
resharper-4.5
usenet
corporate-policy

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