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

  • SEARCH
  • Home
  • 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 8225467
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 7, 20262026-06-07T15:25:41+00:00 2026-06-07T15:25:41+00:00

I added a class called Connect.cs; namespace MovieApp.DAL { public class Connect { public

  • 0

I added a class called Connect.cs;

namespace MovieApp.DAL
{
   public class Connect
   {
      public Connection()  //my class needs to have a return type
      {
        var connStr = ConfigurationManager.ConnectionStrings["Entities"];
        ObjectContext context = new ObjectContext(connStr.ConnectionString);
        var movieContext = context.CreateObjectSet<Movie>();
        return movieContext;
      }
   }
}

then i have in my controller class:

namespace MovieApp.Controllers
{
    public class MovieController : Controller
    {
        public ActionResult Index()
       {
        Connect connection = new Connect(//and what will i put here??);
        var movies = connection.OrderBy(m => m.Title);
        return View(movies);
        }
}

obviously i get errors because I do not know how to do this.
Of what type will movieContext be?
How do I get this code to work please?
thanks!

  • 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-06-07T15:25:43+00:00Added an answer on June 7, 2026 at 3:25 pm

    Something like this?

    public ObjectSet<Movie> Connection()
    {
        var connStr = ConfigurationManager.ConnectionStrings["Entities"];
        ObjectContext context = new ObjectContext(connStr.ConnectionString);
        var movieContext = context.CreateObjectSet<Movie>();
        return movieContext;
    }
    

    And then in your controller:

    public ActionResult Index()
    {
        Connect connection = new Connect();
        var movies = connection.Connection().OrderBy(m => m.Title);
        return View(movies);
    }
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have a class called DataStructures where I have a set of public static
I have a public method (called getMusic) in a class called Favorites. getMusic has
I have a connection class that uses NSURLConnection to connect to the server. While
I have a model class called House: public class House { public House() {
I have a class called game that extends View that is added to a
I have a class called User, that needs to include a module. The class
In a C# Winforms (3.5) application I have added a class that contains many
I'm using scrollto, and I'm wanting to have a class added when it scrolls
<label>Search: <input type=text aria-controls=company></label> Using Datatables , how would i added a class to
I have an activity view that I have added in AppDelegate class to tap

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.