Wednesday, 15 July 2015

c# - Difference between query a database through an EF context versus Web API -



c# - Difference between query a database through an EF context versus Web API -

i have winforms app uses entity framework communicate sql database on local network. nice because can create database context , utilize linq manipulate data.

i'm building mvc app hosted in different location need access same database used winforms app. hoping expose info through web api, i've started doing looks have build urls homecoming info need api rather beingness able communicate through context object i'm accustomed doing.

for example, if want roles user in can this:

var roles = u in ctx.user u.id == 1 select u.roles;

if i'm understanding correctly, if using web api have build url parameters, create http request using httpcontext, results response. correct?

you correct. using web api adds additional layer here. what's nice can move lot of logic application api layer , have cleaner separation of concerns. means add together additional clients (perhaps don't back upwards ef or may not .net based, such iphone apps) talk same web api.

note doesn't have url contains parameters, can in request body. , there frameworks can automate creating requests when provide typed parameters. don't utilize httpcontext (which asp.net thing server side anyways, not client).

c# entity-framework asp.net-web-api

No comments:

Post a Comment