Skip Navigation LinksHome / Community & Support / Developer Productivity Tools Forums / OpenAccess ORM > OpenAccess ORM Free Edition > does not contain a definition for 'Include'

Answered does not contain a definition for 'Include'

Feed from this thread
  • Michael avatar

    Posted on Nov 20, 2010 (permalink)

    I port MSSQL "Music Store" database to PostgreSQL database for testing MVC2. Now for query database I use Open Acess ORM. For selected code :

    namespace MyMVC.Controllers
    {
        public class StoreController : Controller
        {
            MvcMusicStoreModel storeDB = new MvcMusicStoreModel(); 
      
      
            //
            // GET: /Store/Browse
            public ActionResult Browse(string genre)
            {
                // Retrive Genre and its Associated Albums from database
      
                // ---> HERE IS ERROR!!!
                var genreModel = storeDB.Genres.Include("Albums")
                    .Single(g => g.Name == genre);
                // <--- HERE IS ERROR!!!
      
      
                var viewModel = new StoreBrowseViewModel
                {
                    Genre = genreModel,
                    Albums = genreModel.Albums.ToLIst()
                };
      
                return View(viewModel);
            }

    I got this error :
    Error 1 'System.Linq.IQueryable<MyMVC.Genre>' does not contain a definition for 'Include' and no extension method 'Include' accepting a first argument of type 'System.Linq.IQueryable<MyMVC.Genre>' could be found (are you missing a using directive or an assembly reference?) C:\Users\Michael\Documents\Visual Studio 2010\Projects\MyMVC\MyMVC\Controllers\StoreController.cs 37 45 MyMVC


    Any help?

    Michael

    p.s. If anyone ned Create script for PostgreSQL Music Store, make replay here.

    Reply

  • Answer Damyan Bogoev Damyan Bogoev admin's avatar

    Posted on Nov 22, 2010 (permalink)

    Hello Michael,

    Unfortunately we do not provide support for the Include extension method in our LINQ implementation, but we have it in our to-do list. We will add it to product in the future.
    In fact you could use our Fetch Optimization API to control the amount of data that is fetched during the execution of the queries. Helpful information regarding the API can be found under the following help section as well as in the following blog post.
    You should slightly modify the logic within the Browse method in order to achieve the desired goal:

    FetchStrategy fetchStrategy = new FetchStrategy();
    fetchStrategy.LoadWith<Genre>(g => g.Albums);
    storeDB.FetchStrategy = fetchStrategy;
     
    var genreModel = storeDB.Genres.Where(g => g.Name == genre).ToList().Select(x => new { Genre = x.Name, Albums = x.Albums }).Single();

    I hope that you find the provided information useful.

    Regards,
    Damyan Bogoev
    the Telerik team
    Accelerate your learning with industry's first Telerik OpenAccess ORM SDK. Download today.

    Reply

  • Michael avatar

    Posted on Nov 23, 2010 (permalink)

    Somehow I managed to fix the previous problem. It appears that because the parent-child relationships OA ORM, however pulled the child table, so include was not necessary!

    But your post and solution help with this code (album is in midle of tables Genre and Artist) :
    public ActionResult Index() 
        var albums = storeDB.Albums 
            .Include("Genre").Include("Artist"
            .ToList(); 
       
        return View(albums); 
    }

    Thanks a lot Damyan for solution.

    Michael

    Reply

  • Damyan Bogoev Damyan Bogoev admin's avatar

    Posted on Nov 23, 2010 (permalink)

    Hello Michael,

    I am glad to see that you managed to resolve this issue.
    If any other questions arise please contact us back.

    Sincerely yours,
    Damyan Bogoev
    the Telerik team
    Accelerate your learning with industry's first Telerik OpenAccess ORM SDK. Download today.

    Reply

Back to Top

Skip Navigation LinksHome / Community & Support / Developer Productivity Tools Forums / OpenAccess ORM > OpenAccess ORM Free Edition > does not contain a definition for 'Include'