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 www redirect to non www
Bootstrap Glyphicon Popover
how to return to filled out form from other view in mvc
Edit page with a foreign key constraint fails in Asp.net MVC
MVC pass int from view to controller with a button click
PCL Attribute not seen in MVC ModelMetaDataProvider
How to a publish visual studio solution with two dependencies projects to azure?
EF Core + MVC 6 + .NET Core RC2 - EF not returning results
Can we display linq result in view without using model
EF - work with universal entity in library project, when not specified database entities
asp.net core not detecting classlibrary Model on View during runtime
Using Ajax.BeginForm helper in MVC 5 for uploading picture issue [duplicate]
Decorating class with Authorize assumes Office 365 login, instead of offering choice
how can pass the parametrized ActionResult value through ActionLink()
How to get HtmlHelper.Action() working inside a webforms aspx page
Session variables in MVC 5

Categories

HOME
codeigniter
mocking
lsf
jsp
crf
robotframework
azure-web-sites
linear-programming
chronicle
amazon-kinesis
stripe-payments
ionic3
sweetalert
android-bluetooth
cross-domain
documentation
socrata
hadoop2
proftpd
w3.css
editor
ellipse
calabash-android
export-to-excel
libssh
flow
html-email
procedure
git-bash
jscodeshift
realm-java
nested-set-model
core-location
digital-logic
confidence-interval
buffer-overflow
concurrenthashmap
bluebird
lync
vue-router
ose
hamcrest
outlook-vba
jackrabbit
macvim
weebly
extjs4
csr
essbase
rating
project-centennial
angularjs-routing
log4perl
dump
complement
kony
ammonite
view-source
column-oriented
curly-braces
ispconfig
perspective
jasny-bootstrap
ocsp
sizeof
visual-build-professional
sql-server-2016-express
nuitka
pypyodbc
android-popupwindow
airplay
metalkit
multer
wand
laravel-forge
gulp-rename
selectsinglenode
mailx
base-conversion
scalariform
fortrabbit
excel-charts
boxapiv2
iqueryable
linguistics
eventmachine
nitrogen
cfile
jquery-mobile-popup
onejar
mod-python
llblgenpro
shift
qdebug
wow64
google-authorship
arbtt
hamlc
slimbox
northwind
datadesign
double-precision
google-provisioning-api
sticky-footer
stumbleupon
demoscene
having
staging
wiki-markup
regexbuddy
eclipse-tptp
ants
case-tools

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