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 7734749
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 1, 20262026-06-01T07:19:44+00:00 2026-06-01T07:19:44+00:00

I am using a View / Presenter structure for my project. The project is

  • 0

I am using a View / Presenter structure for my project. The project is a e-comm site with OrderedItems and Products.
When calling GetOrdersItemsByOrderID(orderID), I get an LINQ error.

LINQ to Entities does not recognize the method ‘DAL.Views.ProductView GetProductBySku(System.String)’ method, and this method cannot be translated into a store expression.

I know that LINQ does not like dynaimc content within its query so the proplem is the SELECT
Product = Presenters.ProductsPresenter.GetProductBySku(c.productSKU)

I dont know how to Build the GetOrdersItemsByOrderID TOLIST while also have another GetProductBySku method filling the field ProductDetail

/—————-/

public static List<OrderItemsView> GetOrdersItemsByOrderID(int orderID)
{
    using (var ctx = new ProductEntities())
{

    var result = ctx.OrderedItems.Where(o => o.orderID == orderID)
        .Select(c => new OrderedItemsView
                         {
                             OrderItemID = c.orderItemID,
                             OrderID = c.orderID,
                             ProductSku = c.productSKU,
                             ProductPrice = c.productPrice,
                             ProdQuantity = c.prodQuantity,
                             ProductDetail = Presenters.ProductsPresenter.GetProductBySku(c.productSKU)
                         }).ToList();
    return result;
    }
}

/—————-/

public class OrderedItemsView
    {
        public int OrderItemID { get; set; }
        public int OrderID { get; set; }
        public string ProductSku { get; set; }
        public decimal ProductPrice { get; set; }
        public int ProdQuantity { get; set; }
        public decimal? ProductWeight { get; set; }

      public ProductView ProductDetail { get; set; } <-- Get Product Details
    }

/—————-/

public static Views.ProductView GetProductBySku(string sku)
    {
    using (GroupProductEntities ctx = new GroupProductEntities())
    {
        //-------------------------------------------------------------------//
        var results =
            ctx.Products.Where(p => p.clientID == Config.ClientID && p.productSKU == sku)
            .Select(p => new Views.ProductView
                             {
                                 ProductID = p.productID,
                                 ClientID = p.clientID,
                                 CategoryID = p.categoryID,
                                 ProductName = p.productName,
                                 ProductImage1 = p.productImage1,
                                 ProductPrice = p.productPrice,
                                 ProductInventory = p.productInventory,
                                 ProductSku = p.productSKU,
                             }).FirstOrDefault();
        return results;
    }
 }

/—————-/

public class ProductView
{
    public int ProductID { get; set; }
    public int? CategoryID { get; set; }
    public string ProductName { get; set; }
    public string ProductShortDesc { get; set; }
    public string ProductImage1 { get; set; }
    public decimal? ProductPrice { get; set; }
    public decimal? ProductInventory { get; set; }
    public string ProductSku { get; set; }
}

/—————-/

  • 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-01T07:19:46+00:00Added an answer on June 1, 2026 at 7:19 am

    You might be able to get away with adding a “ToList” to execute the query before you call that method.

    Try this:

       var result = ctx.OrderedItems.Where(o => o.orderID == orderID).ToList()
            .Select(c => new OrderedItemsView
                             {
                                 OrderItemID = c.orderItemID,
                                 OrderID = c.orderID,
                                 ProductSku = c.productSKU,
                                 ProductPrice = c.productPrice,
                                 ProdQuantity = c.prodQuantity,
                                 ProductDetail = Presenters.ProductsPresenter.GetProductBySku(c.productSKU)
                             });
    

    I moved your ToList() up a bit. You may still need one at the end of the Select as well.

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

Sidebar

Related Questions

I am using the Model-View-Presenter pattern in a WinForms project and one problem (among
I'm currently implementing a project using asp.net, c# and the MVP (Model-View-Presenter) pattern. The
I'm building an application using the Supervising Controller pattern (Model View Presenter) and I
I have a View (created using Backbone.View.extend) and a JSON object, I actually get
I'm using Model-View-Presenter framework. When Loading a page, I'm having trouble setting the selected
I am using the Model-View-Presenter pattern for a web page. Should the presenter be
I've set up a little n-tier web application using MVP (Model View Presenter) in
how populate ComboBox and DataGridView using MVP (Model-View-Presenter). Actually i have something like this:
In trying to write more testable Java code, I have been using the Model-View-Presenter
Is using view in db design right method or we should handle it code

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.