public ProductDetailUI getProductDetail(int productID) { MarketplaceWebPortalEntities db = context; var product = from pRecord in db.Products where pRecord.ProductID == productID join moRecord in db.Models on pRecord.ModelID equals moRecord.Model_id join maRecord in db.Manufactures on pRecord.ManufactureID equals maRecord.ManufactureID //join sRecord in db.Series //on pRecord.SeriesID equals sRecord.SeriesID join subRecord in db.SubCategories on pRecord.SubCategoryID equals subRecord.SubCategoryID join proRecord in db.Properties on pRecord.PropertyID equals proRecord.PropertyID join appRecord in db.Applications on proRecord.ApplicationID equals appRecord.ApplicationID select new ProductDetailUI { CategoryID = 1, CategoryName = "Electrical", model_name = moRecord.model_name, model_year = moRecord.model_year, series_name = "Same Series", //sRecord.SeriesName, ManufactureName = maRecord.ManufactureName, Application = appRecord.MountingLocation, use_type = "Commercial", MountingLocation = appRecord.MountingLocation, air_flow = proRecord.air_flow, power_min = proRecord.power_min, power_max = proRecord.power_max, operating_voltage_min = proRecord.operating_voltage_min, operating_voltage_max = proRecord.operating_voltage_max, fan_speed_min = proRecord.fan_speed_min, fan_speed_max = proRecord.fan_speed_max, number_of_fan_speed = proRecord.number_of_fan_speed, fan_sweep_diameter = 60, height_min = proRecord.height_min, height_max = proRecord.height_max, weight = proRecord.weight, Accessories = "No Accessories" }; List <ProductDetailUI> oList = product.ToList(); List <ProductDetailUI> rList = new List <ProductDetailUI>(); ProductDetailUI nUI = new ProductDetailUI(); foreach (ProductDetailUI item in oList) { Debug.WriteLine(item.CategoryName); Debug.WriteLine(item.ProductID); nUI = item; } return(nUI); }
//inject the class that extends DbContext public ProductDetailsRepository(MarketplaceWebPortalEntities context) { this.context = context; }