StrataFrame Forum

Event Handlers

http://forum.strataframe.net/Topic52.aspx

By Daniel Essin - 11/21/2005

I have inported a database into the deployment toolkit and used that as the data source for a project. I have created 2 bo's in the project and mapped them to 2 tables in the deployment kit. When building the project I get the following errors:

Error   1   The name 'boAllergies_CheckRulesOnCurrentRow' does not exist in the current context   E:\_work.NET\MyBusinessObjectLibrary\MyBusinessObjectLibrary\boAllergies.Designer.cs   



Error   2   The name 'boAllergies_SetDefaultValues' does not exist in the current context   E:\_work.NET\MyBusinessObjectLibrary\MyBusinessObjectLibrary\boAllergies.Designer.cs   



Error   3   The name 'boAdressFavorites_CheckRulesOnCurrentRow' does not exist in the current context   E:\_work.NET\MyBusinessObjectLibrary\MyBusinessObjectLibrary\boAdressFavorites.Designer.cs   



Error   4   The name 'boAdressFavorites_SetDefaultValues' does not exist in the current context   E:\_work.NET\MyBusinessObjectLibrary\MyBusinessObjectLibrary\boAdressFavorites.Designer.cs   



Am I supposed to create these handlers or are they supposed to be written by the framework?
By Daniel Essin - 11/21/2005

Additional Info:



This is the problem. I changed the Project Name and Default Namespace in the Project Properties dialog of the BO Mapper. When I click "Rebuild All", The bo.designer.cs files get rebuilt with the new namespace BUT the bo.cs files get generated with the obsolete namespace.



I cannot tell where this info is being stored (nowhere obvious) but it is not being correctly updated when the namespace property is edited.
By StrataFrame Team - 11/21/2005

You're using C#, and the Namespace defined within the configuration for each business object within the Business Object Mapper does not match the namespace of the business object's main code file. So, when the designer file is created, it's created in a different namespace...



We're working on removing the namespace requirement from the Business Object Mapper so that it will just use the namespace of the main code file, but in the mean time, you will have to configure your business objects with their proper namespace in the Business Object Mapper.
By Daniel Essin - 11/21/2005

More additional info:



I got it backwards. the bo.cs is either generated correctly or not touched, the bo.designer.cs is generated incorrectly.
By Daniel Essin - 11/21/2005

What I meant to say is that after changing the default namespace for the project and the default namespace in the BO mapper, the mapper is still generating namespaces that reference the name that I initially supplied to the mapper but subsequently altered.



It seems to have a memory for the phantom, obsolete name in preference to the name that now shows in the property form when generating code.
By Daniel Essin - 11/21/2005

More...



The problem is that when the BO Mapper first processes a new BO it puts the current default namespace into each record in DTEPreferences in the StrataFrame database. If you subsequently edit the namespace property of the project, the edit does not propagate to DTEPreferences.
By Trent L. Taylor - 11/21/2005

Since C# automatically uses a namespace when an object is created the Business Object Mapper project should be setup with a default namespace to help avoid this issue.  There are several ways to achieve this, the default namespace for the Business Object Mapper project or by overriding the namespace for each business object individually.

Let's assume the namespace of the project (and the business object's .cs file) is MyNameSpace.  To set the default namespace for all business objects when they are mapped, do the following:

1.) Open the Business Object Mapper
2.) Click on the project that needs to be modified
3.) On the configuration panel on the right, click Modify Project Properties
4.) Set the default namespace to match the namespace of the C# project.
5.) Rebuild the partial classes.

This will create the partial class with the namespace you just specified in the "default namespace" property.  To make sure the partial was generated properly open the business objects .designer.cs file and look for the namespace tag.  This will be set to the specified setting from above.  Open the business objects .cs file and make sure the same namespace is specified. 

Phantom Business Object

The phantom business object only appears within the Business Object Mapper when the namespace in the business object's .cs class does not match the namespace in the business object's .designer.cs.  This is usually due to an invalid namespace specified in the Business Object Mapper as mentioned earlier.

Bottom Line
The bottom line is that the namespace MUST match in both class files that comprise the business object.  Verify that the namespaces match and this will remove the "Phantom" business object.

By Daniel Essin - 11/21/2005

This is a helpful summary.



The problem I am describing occurs after you do all of that.



IF you change your mind about the namespace and

a) edit the vs2005 default namespace AND

b) edit the project namespace in the BO Mapper AND

c) "rebuild all"

THEN

the changed namespace in the BO Mapper does NOT get pushed down into the definitions of the existing BO's in the database.



The result is that "rebuild all" regenerates xx.designer.cs files that each have the original namespace, not the current one. The projects then fail to compile because one part of the partial class (xx.cs) is in a different namespace from the other partial class (xx.designer.cs). The definitions of the event handlers and the code that uses them end up in different namespaces making the definitions invisible to the code that references the event handlers.
By Trent L. Taylor - 11/22/2005

Daniel,



Change the namespace on the individual business object itself and the changes will take effect. The Default namespace for the BO Mapper project is used when a new business object is associated with a table. But we allow the developer to overwrite individual business objects namespace to allow business objects within the same project to exist in different namespaces. We might look at adding a "Change All" function that changes the individual business objects namespace when changing the default namespace. But as of right now, the BO Mapper works as designed. The reason we do not make a blanket change to all business objects when the default namespace is changed is to allow the developer to have control over the namespace of each individual business object and it could cause far more problems if we arbitrarily changed the individual items. However, we may add an option that allows the developer to "Change All" existing business objects since I can see how this could be helpful.
By Trent L. Taylor - 11/22/2005

A change has been made to the Business Object Mapper that gives you (the developer) three options when changing the default namespace of a Business Object Mapper project.  First, the new namespace can be updated on all business objects within the project.  Second, only business objects that have the same namespace as the old namespace can be updated.  And last, the individual business objects namespace can be left alone.

This will be available in the next update.

By Daniel Essin - 11/22/2005

Thank you. Being able to make a global change will be helpful. I now also see why I was so confused before. On the individual table properties in the mapper, the namespace appears in a field that is not editable. I just discovered that if you expand the advanced options, the namespace appears again in a field that is editable.



That property dialog is not so large. Would it be useful to just show the whole thing all the time rather than to deal with the show and hide function?
By Trent L. Taylor - 11/22/2005

Actually Daniel, the Business Object Mapper will remember the state you leave it in the next update.  Also, the Business Object Mapper window position is remembered as well.  This way you can set the display to your liking and it will be remebered for your next session.  The best of all worlds! Smile