2017-07-24 90 views
-4

我想在這種方法是增加另一個查詢Asp.net網頁API MVC

從產品

選擇這裏給其中產品ID = + ID

但由於清單有sales_line提示錯誤表..如何解決這個問題?誰能幫我?

public List<sales_line> Get(int id) 
    { 
     using (project_smartEntities entities = new project_smartEntities()) 
     { 
      entities.Configuration.ProxyCreationEnabled = false; 
      return entities.sales_lines.SqlQuery("Select * from sales_line where sales_id=" + id).ToList<sales_line>(); 
     } 
    } 
+0

沒有足夠的信息來回答你的問題。添加更多的代碼,你收到的錯誤,並更好地解釋你的需要 – Bardo

+0

我想申請查詢,其中我從產品表中選擇*從銷售表和product_name ..問題是在列表中,它有銷售表,所以它給出錯誤,因爲它沒有產品表 –

+0

仍然不清楚您是否嘗試加入產品表,或者您有將問題結果映射到模型的問題。至少編輯你的問題,並顯示涉及的模型(sales_line,產品),並粘貼確切的錯誤信息。 –

回答

-1

你騙子利用工會SQL

Select *,'a' as type_select from sales_line 
union all 
Select *,'b' as type_select from sales_line1 
+0

它給產品表上的意外的代碼錯誤,這是找不到這行bcz ToList (); –