tavos tavos

tavos tavos

  • NA
  • 163
  • 1.3k

Comparing two table IDs. ASP.NET MVC

Dec 14 2020 10:11 AM
I am currently loading two Orders and Colors tables, I wanted the Colors table to list the items that have the ID equal to Orders. For this, what occurred to me was to assign the IdOrders values ​​to a variable and compare it with my IdOrders (in my table Colors), but it is not possible to assign the database's balance to my variable
 
My tables:
  1. public partial class Orders {  
  2.   public int ID_Orders {  
  3.     get;  
  4.     set;  
  5.   }  
  6.   public Nullable < System.DateTime > Data_Registo {  
  7.     get;  
  8.     set;  
  9.   }  
  10.   public string Num_Encomenda {  
  11.     get;  
  12.     set;  
  13.   }  
  14.   public string Ref_Cliente {  
  15.     get;  
  16.     set;  
  17.   }  
  18. }  
  19. public partial class Colors {  
  20.   public int ID_Orders {  
  21.     get;  
  22.     set;  
  23.   }  
  24.   public int ID_Programa_Malha {  
  25.     get;  
  26.     set;  
  27.   }  
  28.   public int ID_Linha_Cor {  
  29.     get;  
  30.     set;  
  31.   }  
  32.   public string Cor {  
  33.     get;  
  34.     set;  
  35.   }  
  36. }  
I am working with a database already in operation and possible these tables are already used in a sql join but not how to process that information.
 
As I said the first thing I remembered was to do this:
 
My Controller:
  1. var id = from d in db.Orders select d.ID_Orders;  
  2. var color = db.Colors.Where(x =>x.ID_Orders = id).ToList();  
  3. var tables = new EncomendaViewModel {  
  4.   Orders = db.Orders.ToList(),  
  5.   Colors = color.ToList(),  
  6. };  
  7. return View(tables);  
Error in id: CS0029 C# Cannot implicitly convert type to 'int' Erro id
 
 
Is it possible to process the data in this way?
 
Thanks for anyone who can help!
 
------------(Update)---------------
 
Using == cs0019 operator '==' cannot be applied to operands of type error2
 
 
My view in Broswer view

Answers (2)