ObjectDataSource and LINQ technicality?

For posterity's sake List categories should be fine. Properties are exposed via something like : categories0. TempID You can run LINQ against the collection: var catIDs = from cat in categories where cat.ID.

HasValue == true select cat UPDATE_3: Okay, I understand now - you receive an object that looks like: public Guid TempID { get; set; } public Nullable ID { get; set; } public bool Published { get; set; } public int CategoryLevel { get; set; } public int CategoryOrder { get; set; } public DateTime UpdatedDate { get; set; } public Nullable RefParent { get; set; } public bool GotChildren { get; set; } and you need to be able to add collections of child categories? If you cannot inherit the class, I would consume the object by: class MyCategory { // add fields for respective Category properties // or just the following Category category; List subCategories; MyCategory (Category category) { this. Category = category; if (this.category.

GotChildren) { // query TempIDs, Level, etc. From collection of Categories // and assign to subCategories collection } } // add property getters/setters as needed public List SubCategories { get { return subCategories; } } } externally, call: bool TryGetSubCategories (MyCategory myCategory, out DataList myDataList) { if (myCategory. GotChildren) {myDataList. DataSource = myCategory.

SubCategories;} return myCategory. GotChildren; } Updated the method to work in similar fashion to Dictionary.TryGetValue() UPDATE_2: You will need to add a collection ( ICollection List) property to your type: public Guid TempID { get; set; } public Nullable ID { get; set; } public bool Published { get; set; } public int CategoryLevel { get; set; } public int CategoryOrder { get; set; } public DateTime UpdatedDate { get; set; } public Nullable RefParent { get; set; } public bool GotChildren { get; set; } public List SubCategories {get; set;} // add this This will add unlimited depth. I don't see why couldn't use the DataList as your SubItems data type UPDATE: After looking at the DataList class more carefully, you must use an ICollection as the DataSource.

MSDN shows that List.

For posterity's sake... List categories should be fine. Properties are exposed via something like : categories0. TempID You can run LINQ against the collection: var catIDs = from cat in categories where cat.ID.

HasValue == true select cat; UPDATE_3: Okay, I understand now - you receive an object that looks like: public Guid TempID { get; set; } public Nullable ID { get; set; } public bool Published { get; set; } public int CategoryLevel { get; set; } public int CategoryOrder { get; set; } public DateTime UpdatedDate { get; set; } public Nullable RefParent { get; set; } public bool GotChildren { get; set; } ...and you need to be able to add collections of child categories? If you cannot inherit the class, I would consume the object by: class MyCategory { // add fields for respective Category properties // or just the following Category category; List subCategories; MyCategory (Category category) { this. Category = category; if (this.category.

GotChildren) { // query TempIDs, Level, etc. From collection of Categories // and assign to subCategories collection } } // add property getters/setters as needed public List SubCategories { get { return subCategories; } } } ...externally, call: bool TryGetSubCategories (MyCategory myCategory, out DataList myDataList) { if (myCategory. GotChildren) {myDataList. DataSource = myCategory.

SubCategories;} return myCategory. GotChildren; } Updated the method to work in similar fashion to Dictionary.TryGetValue(); UPDATE_2: You will need to add a collection (ICollection, List, etc.) property to your type: public Guid TempID { get; set; } public Nullable ID { get; set; } public bool Published { get; set; } public int CategoryLevel { get; set; } public int CategoryOrder { get; set; } public DateTime UpdatedDate { get; set; } public Nullable RefParent { get; set; } public bool GotChildren { get; set; } public List SubCategories {get; set;} // add this This will add unlimited depth. I don't see why couldn't use the DataList as your SubItems data type.

UPDATE: After looking at the DataList class more carefully, you must use an ICollection as the DataSource. MSDN shows that List inherits from ICollection & ICollection. IList inherits from ICollection; while IList inherits from ICollection.

MSDN also has a sample.

Basicaly, I know how to databind a Datalist to an ObjectDataSource. What I'm not confortable with is how to databind my DataList, which can have many children datalist, to a single List that contains all level on the first dimension. Don't know if I tell it correctly... – Simon Dugré Apr 25 at 16:56 And, about your response, you must bind the datalist on every postback otherwize it don't shows on postbacks – Simon Dugré Apr 25 at 17:01 @Simon: the postback portion is copied directly from MSDN - this is the sample they provide.

How do you know how deep your child objects will go? – IAbstract Apr 25 at 17:08 1 @Simon: see Update 3 - I think this will help you out... – IAbstract Apr 25 at 18:10 1 Simon, are you speaking about Silverlight/WPF data binding? – Judah .

Another technicality is that the number of children is not static. We presently have 3 depth but it can easly have 5. Must say that I can't change where and how data are return because it's how it comes from an external API.

I cant really gove you an answer,but what I can give you is a way to a solution, that is you have to find the anglde that you relate to or peaks your interest. A good paper is one that people get drawn into because it reaches them ln some way.As for me WW11 to me, I think of the holocaust and the effect it had on the survivors, their families and those who stood by and did nothing until it was too late.

Related Questions