We use cookies to give you the best experience on our website. If you continue to browse, then you agree to our privacy policy and cookie policy. Image for the cookie policy date

Nested Property Goes Infinite

Hi, I am associating one entity to the GGC. GGC has ShowNestedPropertiesFields = true. My entity has one property of its own type like self join. What happens is like it hangs because it finds the same typeof of property in the entity. Example: public class Manager { public string Name { } public Manager Parent { } } As you can see here, Manager class refers to itself. Please let me know how can i stop this recursove looping?

6 Replies

ST stanleyj Syncfusion Team January 17, 2006 02:53 PM UTC

Hi salim, Could you please give me some more information regarding how to implement this issue in a sample. I would really appreciate it, if you could provide us a sample code that exhibits this behavior. We will try analyzing it here. Regards, Stanley


AD Administrator Syncfusion Team January 18, 2006 04:53 AM UTC

Hi Salim, Please try setting the "ShowNestedPropertiesFields = false" and let us know if it helps. Best Regards, Jeba.


SA Salim Amin Padela January 19, 2006 10:25 AM UTC

Hi, ShowNestedproperties = false will work. My problem here is different. let me explain you in detail what i want. I have one class named as Manager. Now in database, i have one table as Manager which holds the data. This table has opne column named as ReportTo. If this column is blank, it means the person is Head. For doing this i have created one property in the Manager Class which refers to itself because it is a self join. I need to refer itself to get the Head of the person which is on the record. Let me describe my class. Class Manager { string _empName; Manager _reportsTo; string EmpName { get { return _empName; } set { _empName=value; } } Manager ReportsTo { get { return _reportsTo; } set { _reportsTo = value; } } } Now here you can see that Manager Class refers itself to hold the data of the Manager of the current employee. I want to display the Manager Details of the Head only once. Now what is happening is I am setting ShowNestedFieldProperties = true. So it goes infinite times to cretate the columns of Manager. I dont want to make it loop recursively. I hope you got it what i am here describing you. Still if not then i will send you dummy project and that will clearify what i want to do. Please let me know the solution to stop the recursive loop.


AD Administrator Syncfusion Team January 19, 2006 03:52 PM UTC

Hi Salim, with the special setup you have I think it is actually best to not let the engine automatically populate the nested fields. Instead you can manually populate fields as follows: _testGrid.ShowNestedPropertiesFields = false; _testGrid.TableDescriptor.Fields.Clear(); _testGrid.TableDescriptor.Fields.Add("Name"); _testGrid.TableDescriptor.Fields.Add("TestEmployer.Name"); _testGrid.TableDescriptor.Fields.Add("TestEmployer.TestPatient"); _testGrid.TableDescriptor.Fields.Add("TestEmployer.TestPatient.TestEmployer"); etc. _testGrid.DataSource = list; Stefan


SA Salim Amin Padela January 20, 2006 03:43 AM UTC

In this case i have to hard code the column names and column descriptors. I am not permitted to do so. My domain entity can be changed. I am not supposed to change the code if my domain entity is changed. I hope you are getting my point.


AD Administrator Syncfusion Team January 20, 2006 04:43 PM UTC

Salim, you can also dynamically loop through the properties in your list and add them manually to the Fields collection. For example try this: FieldDescriptorCollection fields = _testGrid.TableDescriptor.Fields; fields.Clear(); PropertyDescriptorCollection pdc = ListUtil.GetItemProperties(list); for (int n = pdc.Count-1; n >= 0; n--) { PropertyDescriptor pd = pdc[n]; if (ListUtil.IsComplexType(pd)) { // put here condition when to include nested properties. AddNestedProperties(fields, pd.Name, pd.PropertyType, 0); } else fields.Add(pd.Name); } _testGrid.DataSource = list; void AddNestedProperties(FieldDescriptorCollection fields, string prefix, Type propertyType, int level) { PropertyDescriptorCollection pdc = ListUtil.GetItemProperties(propertyType); if (pdc.Count > 0) { foreach (PropertyDescriptor pd in pdc) { // Add here criteria when to step into nested type. if (ListUtil.IsComplexType(pd) && level < 2) AddNestedProperties(fields, prefix + "." + pd.Name, pd.PropertyType, level+1); else fields.Add(prefix + "." + pd.Name); } } } I have attached a sample with this code. Other options you have is to set the Browsable(false) attribute for certain properties. But that is then an all or nothing solution. You could however have a derived class for "TestPatient" and only set Browsable(false) in that derived class for the property. As I understand your problem, the key is that in your scenario you want to get the nested properties for the same type only if it is not more than 2 levels deep. The sample I mentioned before is here: TestSyncfusionIssue.zip Stefan

Loader.
Live Chat Icon For mobile
Up arrow icon