'System.StackOverflowException' occurred in mscorlib.dll
I am building a rich domain model application why has cyclic references.And the exception I get is the classical one.. 'System.StackOverflowException' occurred in mscorlib.dll
As I have two objects that referecence each other , each time I try to load one it will try to load other,which will turn try to load the first one,and so on.until I get System.StackOverflowException' occurred in mscorlib.dll.Avoiding this requires me to write a null object pattern which I do not like that much(using the deffereed loading) as it gets messy so quickly as I create a an empty object and try to insert that into an identity map which stops the recursive loading.
My question is how is it possible to use deferred loading in this case and is it possible to tell the framework build identityMap has loaded the object.?
if is there no event like INotifyLoaded?did they forget to write it?
U have miss understood the whole concept of this thread!!!!!!!!!
LinQ is directly related to this subject and after the launch of vs 2008 people will build much mode domain model based applications with the linQ framework most using DlinQ or LinQ to SQL.
and the rich domain models comes with rich constructors where we will need deferred loading(Lazy loading) and loading of relations which will eventualy reference each other.!!!!!!!
u have moves the thread to the wrongest place in the microsoft forums as my concern was business related not machine related.(stack overflow is the result what happens if we design higly complex object graphs).
such as a customer will reference its categories and its categories will have customers .Each time ? try to load categories it will load customers and customers will load categories.And I need to be able to tell the identity map(build by the ado.net team) , if it had loaded the same objects before......!!!!! there fore I need events on the Table<> classes......!!!
please move this thread to where ever related to vs 2008 and LinQ related forums....
This is the right place to discuss this topic.
Is there more specifics you can supply so we can understand your problem? LINQ to SQL uses deferred loading by default and has an identity map, so none of what you are experiencing should be happening. Are you using the default code-generated objects or are you doing something of your own?

ok here is the case explained ....
DATABASE > Customers Table has one to many relationship with categories.
I have three namaspaces.
GATEWAY > The way to goto database
> where ? place the datacontexts and ? put the customer and category table....
> and it generates the Table<CUSTOMER> and Table <CATEGORY>
MAPPER > Every domain class has a mapper class where it has static methods and return domain objects ,
> it is also uses the GATEWAY to return
> Customer_Mapper class loads the customer with a list of Categories
> Categories_Mapper class loads a category with a Customer
DOMAIN > Where my OO rich domain comes into the place ,
>the domain has two classes is CUSTOMER and one class is CATEGORY.
>I have bidirectional design ....where customers has a generic list of Categories and the Categories have a related customer
UI > customer.aspx From the UI when I use want to get a customer like.
>Customer Anders = Customer_Mapper.FindByID(customerID);
this process loads the first the customer than the categories and the categories loads the customer and that loads the category and so on.
so anyway to the point I need to be able to know if the object is loaded before so I can stop the recursive loading and get rid of the 'System.StackOverflowException'.
and by the time linQ (and related staff) hits the road , the microsoft architectures will evolve from table modules(mostly dataset oriented) to rich domain models.
help needed on this issue thanks 