deanlee17
asked on
WPF Master detail grids using LINQ
Hi guys,
What is the easiest way to achieve my goal? Should I have 2 linq queries run when the program is launched and save the results in a public list and then assign a list to each of the grids? Then have a selected row change event acting as a filter to the child's list?
Hope that makes sense?
Thanks,
Dean.
p.s I should mention that these grids will be used to add, remove and edit data.
What is the easiest way to achieve my goal? Should I have 2 linq queries run when the program is launched and save the results in a public list and then assign a list to each of the grids? Then have a selected row change event acting as a filter to the child's list?
Hope that makes sense?
Thanks,
Dean.
p.s I should mention that these grids will be used to add, remove and edit data.
What if I just said, "Yes"...would that suffice?
ASKER
Hi TheLearnedOne,
haha you could just say "Yes", is this the way you would done it?
haha you could just say "Yes", is this the way you would done it?
If you are a cat lover, then I apologize for the statement, "there are many ways to skin a cat". I assume that you are using ObservableCollection, and that you are binding to the grids dynamically in code.
ASKER
haha I don't like cats, but I wouldn't skin one. Either way i'm not offended.
This is how I am binding....
This is how I am binding....
private void LoadEnquiryHeader()
{
using (var context = new AscentEntities())
{
grdEnquiryHeader.ItemsSource = context.Qte_Header;
}
}
private void LoadEnquiryFooter()
{
using (var EnqFooter = new AscentEntities())
{
var EnqFooterVar = (from d in EnqFooter.Qte_Lines where d.LinesAstuteRef == Instance_EnquiryCustomer.AstuteRef select d).ToList();
grdEnquiryLines.ItemsSource = EnqFooterVar;
}
}
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
ASKER
Do they run any faster? Or just personal preference?
LINQ queries compile into Lambda expressions, so it is personal preference. I just feel that they are a cleaner way of approaching the same thing. This is contrary to what others believe, but I don't mind being different.
Query Syntax and Method Syntax in LINQ (C#)
http://msdn.microsoft.com/en-us/library/vstudio/bb397947.aspx
Query Syntax and Method Syntax in LINQ (C#)
http://msdn.microsoft.com/en-us/library/vstudio/bb397947.aspx
Query syntax and method syntax are semantically identical, but many people find query syntax simpler and easier to read. Some queries must be expressed as method calls. For example, you must use a method call to express a query that retrieves the number of elements that match a specified condition. You also must use a method call for a query that retrieves the element that has the maximum value in a source sequence. The reference documentation for the standard query operators in the System.Linq namespace generally uses method syntax. Therefore, even when getting started writing LINQ queries, it is useful to be familiar with how to use method syntax in queries and in query expressions themselves.