Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • Home
  • SEARCH
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 7593229
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 30, 20262026-05-30T21:06:59+00:00 2026-05-30T21:06:59+00:00

I’m researching the new ASP.NET MVC4 Web API framework. I’m running Visual Studio 2011

  • 0

I’m researching the new ASP.NET MVC4 Web API framework. I’m running Visual Studio 2011 beta on the Windows 8 consumer preview.

My problem is that none of the official samples for the new Web API framework use any kind of database backend. In the past, I’ve been able to create a local SQL CE database and serve it up via a WCF Data Service using Entity Framework as the ORM. How do I do the same with Web API?

Also, is this even a valid question? Should I just keep using a WCF Data Service if I want to expose an Entity Framework mapped SQL CE database? It seems to work fine, other than not offering the flexibility to choose response formatters that I might get with web api.

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-30T21:07:01+00:00Added an answer on May 30, 2026 at 9:07 pm

    If you look at the official Contact Manager sample, you’ll find that the Repository Pattern is used to access the data layer.
    Also, bear in mind that in this particular example there’s also DI via Ninject.

    In my case I’ve easily plugged this onto an already existing EF model.

    Here’s an example for a repository implementation

    ///MODEL
    public class SampleRepository : ISampleRepository
    {
    
        public IQueryable<Users> GetAll()
        {
            SampleContext db = new SampleContext();
            return db.users;
        }
    
        [...]
    }
    
    ///CONTROLLER
    private readonly ISampleRepository repository;
    
    public SampleController(ISampleRepository repository)
    {
        this.repository = repository;
    }
    
    //GET /data
    public class SampleController : ApiController
    {
        public IEnumerable<DataDTO> Get()
        {
            var result = repository.GetAll();
    
            if (result.Count > 0)
            {
                return result;
            }
    
    
            var response = new HttpResponseMessage(HttpStatusCode.NotFound);
            response.Content = new StringContent("Unable to find any result to match your query");
            throw new HttpResponseException(response);
        }
    }
    

    Your mileage may vary though, and you might want to abstract out some of this data access even further.
    Good news is that plenty of patterns and ideas that you may have already used on MVC-based projects are still valid.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

link Im having trouble converting the html entites into html characters, (&# 8217;) i
That's pretty much it. I'm using Nokogiri to scrape a web page what has
Seemingly simple, but I cannot find anything relevant on the web. What is the
I have a French site that I want to parse, but am running into
I want use html5's new tag to play a wav file (currently only supported
I am currently running into a problem where an element is coming back from
I'm parsing an RSS feed that has an &#8217; in it. SimpleXML turns this
I have a string like this: La Torre Eiffel paragonata all&#8217;Everest What PHP function
I'm making a simple page using Google Maps API 3. My first. One marker
I have just tried to save a simple *.rtf file with some websites and

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.