11 private IndustryService industryService;
12 protected IndustryService iService
13 {
14 get
15 {
16 if (industryService == null)
17 industryService = new IndustryService();
18
19 return industryService;
20 }
21 }
22 protected void Page_Load(object sender, EventArgs e)
23 {
24 int addressID = 1;
25 gvTest.DataSource = iService.GetAll();
26 gvTest.DataBind();
27
28 //And even can get to something like this no problem
29 gvTest2.DataSource = iService.GetByAddressIDFromIndustryAddress(addressID);
30 gvTest2.DataBind();
31 }
What I'm not getting is DeepLoad. I went to the samples page (http://nettiers.com/Samples.aspx) which has at the bottom of page: Working with the Code
string custId = "TRAIH";
//I get a single instance of the customer I want.
Customers customer = DataRepository.CustomersProvider.GetByCustomerID(custId);
Type [] typesToDeepLoad = new Type[] { typeof(TList<Orders>), typeof(TList<Products>) };
//go further than one level down object graph
bool goMoreThanOneLevelDeep = true;
// I'm going to deep load this customer, but I only want
// to see his orders and the products that he's made,
// I really don't care about the line items
// But the neat thing is that the relationship to products is through // line items.
/// the object graph looks somethign like this
/// - Customer
/// --Order
/// ---OrderDetails
/// ---ProductCollection
/// --CustomerDemographics
/// --CustomerDemographicsCollection_From_CustomerCustomerDemo
/// (a strangely named northwind thing, but shows how many to many relationships work.)
DataRepository.CustomersProvider.DeepLoad(
customer, // my customer
goMoreThanOneLevelDeep, //go further than one level down object graph
DeepLoadType.IncludeChildren, //be Inclusive, instead of exclusive
typesToDeepLoad );
|
I tried my own example which is good but I don't know what to do with it to get it bindable to a control. Don't know if it needs to be cast to something or if I'm totally off track.
22 protected void Page_Load(object sender, EventArgs e)
23 {
24 TheLocalScene.Entities.Industry industry = DataRepository.IndustryProvider.GetByIndustryID(idIndustry);
25 Type[] deepLoadTypes = new Type[]
26 {
27 typeof (TList<Engineer>)
28 };
29
30 DataRepository.IndustryProvider.DeepLoad(industry,
31 true, DeepLoadType.IncludeChildren, deepLoadTypes);
32
33 int idIndustry = 1;
34 gvTest.DataSource = ???
35 gvTest.DataBind();
36 }
I got heaps more questions going through my head but this is a good start.
I just had a quick look again before posting and tried using the Service Layer DeepLoad methods such as:
GridView1.DataSource = iService.DeepLoadByIndustryID(1, true, DeepLoadType.IncludeChildren, deepLoadTypes);
but get error saying Data source is an invalid type. It must be either an IListSource, IEnumerable, or IDataSource. And this is where I get a bit confused. What make deepload so different.
I'm going to put a sample database together based on what I'm trying to do so I can upload here and maybe someone can take a quick look.
Appreciate your work :)
Thanks
btw. found a cool tool for visual studio to copy code as html: http://scottonwriting.net/sowblog/posts/9268.aspx