What Is Generated By The Kinetic Framework?

You just generated your business framework. Great. Now you're ready to go!

But what exactly did you get?

In your root folder, you should have a solution file, named after your Namespace you used while generating. You'll also have another folder named after your DomainNamespace you used when generating. If you selected StoredProcedures for your SQLType, then you'll also have a Database folder.

In that Database folder, you'll find a database project, with the standard folders it starts with, but under the Create Scripts folder, you have a Stored Procedures folder, which has all of your scripts in it. They are all in separate files, and you'll need to run these against the database before you get too far.

In the other folder (Domain, Business, Core, or whatever you called it) is the core of the framework. The files in here are your business entities. Each one has a <entity>.cs file and a Generated.<entity>.cs file. When you open the project, the Generated.<entity>.cs file will be a sub-item of the <entity>.cs file, so it's there, but hidden.

In the Framework folder, you'll find the standard files for the Kinetic Framework:

1. EntityBase - every entity inherits from EntityBase. This provides a default set of methods and properties, default implementations for some methods, and a definition of a standard interface our entities will have. This is also responsible for loading and initializing entities from database readers.
2. EntityList - this provides us with a custom generic collection we can use for lists of our entities. It handles loading and saving of child collections for an entity.
3. EntityListReadOnly - this gives us a way to have a read-only collection that will not get saved when we update our entities.
4. DatabaseColumnAttribute - we use this attribute in our entities to flag a column as coming from the database. You can use this in your own custom objects to have them loaded automatically by the framework.
5. EntityEventArgs and EntityCancelEventArgs - our entities have a few events that you can handle, and we pass along custom event arguments. We typically have an "ing" and a "ed" event - Saving and Saved, Inserting and Inserted, etc. The "ing" event will use the EntityCancelEventArgs, which allows the handler to cancel the pending event. So by saying e.Cancel = true; in the Saving event, we can prevent a Save from happening.
6. SqlHelper - this is a fairly standard SQL Helper class that allows us to access SQL Server. It relies on a ConnectionString being in the ConnectionStrings section of your config file, and it should be called "ConnString" - yes, it's limited, and it's on our list of updates to make.
7. ISearchable and ISavable: Two interfaces that are used to specifiy that our list is searchable and that our entities are savable.
8. MinToEmptyTypeConverter: An attribute to make a friendly display of min values.

I'll go into more details on the framework files at another time. For now, that's good enough to get you going.

Back to the domain folder. The <entity>.cs file will be where you'll add your custom code. The Generated.<entity>.cs file is designed to be left alone, so it can be regenerated if you need to. This isn't a hard and fast rule, but be aware that the file will get overwritten if you regenerate.

The Generated.<entity>.cs file has most of the guts of your business entities in it. It has all of the properties for each database column. It has Properties for foreign key relationships - an Order will have a Customer property for the customer who owns the order. It will also have collections for entites that have foreign keys to it - an Order will have a collection of OrderDetails. There are static methods to create each object, as well as member methods to create objects - if you have an Order object called order, you can call order.CreateOrderDetail(); to get a new OrderDetail object that is related to the Order. It has a public Save() method that knows what children objects need to be saved - if you have a customer entity, change the name, add an order with two order lines, and call customer.Save() it will update the customer, insert the Order and insert all of the OrderDetail rows. There's more, which I'll cover later in more details.

Lastly, you'll get a project file that includes all of the above files.

Open the solution, build, and you're ready to add your UI to the solution!

Last edited Jul 17, 2008 at 2:01 AM by RossCode, version 5

Comments

No comments yet.