0

我在数据访问方面遇到了间歇性问题,所以我正在重建我的项目。我有一个 3 层架构,使用 Linq to Entities 和我的 App_Data 文件夹以及我的数据库在 DATA (DL) 层中。数据的唯一连接字符串位于数据层 (DL) web.config 中。

我在 UI 中的“var GetFeatured”语句中收到一条错误消息,指出“类型 'DL.RESTAURANT' 是在未引用的程序集中定义的。您必须添加对程序集 'DL 的引用。” 我在 UI 中引用了业务逻辑层,而业务逻辑层引用了 DL。我错过了什么?

用户界面代码隐藏

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;

业务逻辑层

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;
    }
  }
}

数据层 (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;
    }
  }
}
4

1 回答 1

0

在您的 UI 项目中添加对 DL 的引用。由于您在 UI 项目中使用该类型,因此您需要对其进行引用。

于 2011-12-10T19:31:53.477 回答