0

I have been having intermittent trouble with data access so I'm rebuilding my project. I have a 3-tiere architecture using Linq to Entities with my App_Data folder with my database in by DATA (DL) layer. The only connection string to the data is in the Data layer (DL) web.config.

I am getting a error message in my UI in the 'var GetFeatured' statement that states that "The type 'DL.RESTAURANT' is defined in an assembly that is not referenced. You must add a reference to assembly 'DL." I have a reference in the UI to the Business Logic layer and the Business Logic layer has a reference to DL. What am I missing?

USER INTERFACE CODE-BEHIND

BLgetFeatured obj2 = new BLgetFeatured();
            int one = 29;
            int two = 54;
            int three = 49;
            int four = 41;

            int restID = one;
            var GetFeatured = obj2.getFeatured(restID);

   var GetFeatured = obj2.getFeatured(restID);
    litRestName.Text = GetFeatured[0].REST_NAME;
    litRestStreet.Text = GetFeatured[0].REST_STREET1;
    litRestPhone.Text = GetFeatured[0].REST_PHONE;
    litRestCity.Text = GetFeatured[0].CITY.CITY_NAME;
    litRestCuisine.Text = GetFeatured[0].CUISINE.CUISINE_NAME;
    litRestShortDesc.Text = GetFeatured[0].REST_DESC;
    restImage.ImageUrl = "~/Images/" + GetFeatured[0].REST_IMAGE;

BUSINESS LOGIC LAYER

using DL;

namespace BL
{
    public class BLgetRestaurants
    {

    public List<RESTAURANT> getRestaurants(string cuisineName, string cityName, string priceName, string ratingName)
    {
        DLgetRestaurants obj = new DLgetRestaurants();
        var restaurantList = obj.getRestaurants(cuisineName, cityName, priceName, ratingName);
        return restaurantList;
    }
  }
}

Data Layer (DL)

namespace DL 
{
  public class DLgetFeatured
  {
    FCGuide db = new FCGuide();
    public List<RESTAURANT> getFeatured(int restID)
    {
        var restList = (from RESTAURANT in db.RESTAURANTs.Include("CUISINE").Include("CITY")
                        where RESTAURANT.REST_ID == restID
                        select RESTAURANT).ToList();

        var result = (from RESTAURANT in db.RESTAURANTs.Include("CITY").Include("CUISINE")
                      where RESTAURANT.CUISINE.CUISINE_ID == RESTAURANT.CUISINE_ID
                      && RESTAURANT.CITY.CITY_ID == RESTAURANT.CITY_ID
                      orderby RESTAURANT.REST_NAME ascending
                      select RESTAURANT).ToList();

        return restList;
    }
  }
}
Susan
  • 1,822
  • 8
  • 47
  • 69
  • You realize that you're directly querying your DAL from the UI and not actually using the business layer class. – tvanfosson Dec 10 '11 at 19:33
  • Sorry, I didnt think so. BLgetFeatured obj2 = new BLgetFeatured(); int one = 29; int two = 54; int three = 49; int four = 41; int restID = one; var GetFeatured = obj2.getFeatured(restID); – Susan Dec 10 '11 at 19:51
  • Take a look at the code above (I have added in more of my code to the UI)and I am believe with the BLgetFeatured obj2 = new BLgetFeatured(), that is going to my BL layer. Is that not correct? – Susan Dec 10 '11 at 19:53
  • tvanfosson- do you have a moment to look at my comments? I would really appreciate your help. – Susan Dec 10 '11 at 20:31
  • You must not have included the relevant code. I don't see a getFeatured method or BLgetFeatured class. Regardless, you're using a RESTAURANT object that exists in the DL and that requires you to include the DL as a reference so it understands the type. – tvanfosson Dec 11 '11 at 00:10

1 Answers1

0

Add a reference to DL in your UI project. Since you are using that type in the UI project, you need a reference to it.

tvanfosson
  • 524,688
  • 99
  • 697
  • 795
  • Does that cause a problem for a 3-tier architechture when I trying to keep my data access separate from the UI? I kinda thought I understood that from my ASP.Net class ...??? – Susan Dec 10 '11 at 20:04