Home User Manual Discussion Forum Search

New Database Table Pattern

This is one of many Patterns.

If you add a new table to the database, you'll have to add a new class in OpenDentBusiness\TableTypes.  You must use this pattern:

Once the file is complete, it MUST BE APPROVED by a senior programmer before continuing.

Some explanations and things to watch out for:
[Serializable] - Because the web service will be passing this object as XML, this tells the CLR to cache the serializer.  [Serializable()] is also acceptable, but deprecated.
TableBase - Inherits from this base class to provide extra functionality.
[CrudColumn(IsPriKey=true)] - The primary key must be of type "long" and must have this attribute.
FK to restaurant. - The parsing stops right there at the period. The three words must be there just like that to parse properly. "FK" space "to" space "tablename" period. Anything after the period is ignored by the parser but will be included in the documentation.
Enum:HotDogToppings - There must not be a space after Enum:, and there must be a space after the enum name. The parsing stops after the space. Leave that space even if that's the end of the comment.
Comments use proper capitalization and have a period at the end.

Serialization Issues
Colors
If the table has any color columns, then they must be handled in a special way due to poor serialization by dotNet.  See the Provider table for an example.  A property must be added as in the example.
List<T>
Similarly, if a type has any generic lists, then they must be handled in a special way due to poor serialization by dotNet. See the Sheet table for an example.
Objects that are not TableBase
If an object needs to be serialized and it is not a TableBase, it still needs to be marked [Serializable()] and it must have a constructor that takes no arguments. An example of this is SheetParameter.

After approval, run the Crud Generator project to create the crud file.  It will notify you that the table is not present in the database.  Click OK to continue.  The new crud file will be in the OpenDentBusiness.Crud folder, but it will need to be added to the project manually before it will be visible in the Solution Explorer.  There will also be a new DataInterface file that has been created that needs to be added to the project.  Find the new query at the bottom of ConvertDatabase.cs, and move it into the conversion script.  Run it to create the table in your test database. 

If you later need a new DataInterface (s class) method, then you can use the Crud project in snippet generator mode.  This is handy when converting over from the old patterns.

For the UI part of the new table, good patterns would be FormPharmacies and FormPharmacyEdit.   Better UI patterns will be documented later.

Moving an Existing Table to Crud

We are gradually moving all tables over to the crud framework. Using the example, add Serializable, Tablebase, and IsPriKey to an existing table file.  Run the Crud Generator project.  It will not complain about a missing database table.  Add the new crud file to the project and to SVN.  Alter the existing OpenDentBusiness.DataInterface file to take advantage of the crud file as much as possible, using the snippet generator as the basis for new methods.  Any unusual situations should be reviewed by a senior programmer.

 

Open Dental Software 1-503-363-5432