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:
- public partial class Orders {
- public int ID_Orders {
- get;
- set;
- }
- public Nullable < System.DateTime > Data_Registo {
- get;
- set;
- }
- public string Num_Encomenda {
- get;
- set;
- }
- public string Ref_Cliente {
- get;
- set;
- }
- }
- public partial class Colors {
- public int ID_Orders {
- get;
- set;
- }
- public int ID_Programa_Malha {
- get;
- set;
- }
- public int ID_Linha_Cor {
- get;
- set;
- }
- public string Cor {
- get;
- set;
- }
- }
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:
- var id = from d in db.Orders select d.ID_Orders;
- var color = db.Colors.Where(x =>x.ID_Orders = id).ToList();
- var tables = new EncomendaViewModel {
- Orders = db.Orders.ToList(),
- Colors = color.ToList(),
- };
- 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