Quantcast
Channel: Windows Forms Data Controls and Databinding forum
Viewing all articles
Browse latest Browse all 2535

Databind two or more entities to a single DataSource (EF6)

$
0
0

Hello mates!

Well, I'm trying to databind my model to the dataGridView's datasource, but I have a problem, a little-big one.

for this example, let's use this model:

public class Orders
{
    public int OrderID { get; set; }
    public decimal Total { get; set; }
    public DateTime Date { get; set; }

    public virtual Clients Clients { get; set; }
}

public class Clients
{
    public int ID { get; set; }
    public string Name { get; set; }
}

I want to display on dataGridView's DataSource the following columns: OrderID, Total and the Name of the Client.

My GetOrders() returns a IList<Orders> and I can get the name through the code.

IList<Orders> orders = GetOrders();
var name = orders.Clients.Name; 
Anyway, my problem is: How do I do this?




Ash nazg durbatulûk, ash nazg gimbatul, Ash nazg thrakatulûk agh burzum-ishi krimpatul.



Viewing all articles
Browse latest Browse all 2535

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>