Home > .NET Domain Model > Extending classes

Extending classes

CodeFluent Entities does not intend to replace developers, instead, its purpose is to take care of all the tedious work so developers can focus on the fun part. Therefore, doing the fun part implies extending the generating code by adding some custom business logic and behavior specific to your application.

As a consequence, the code generated by CodeFluent Entities is easily extensible:

  • generated classes are partials,
  • they do not derive from any base technical class,
  • they are human readable and are absolutely standard .NET code,
  • they implement by default a set of interfaces to make your life easier when using them (data binding, validation, etc.)

This being said, how does it go in practice if a developer wants to add some custom logic before his entity is saved?

CodeFluent Entities provides a set of life-cycle event rules, such as those in the screenshot below, which let you tie-in at any stage of the life-cycle of an entity: when it’s serialized, before or after validation, before or after save, before or after a record is read, etc.


Adding a life-cycle rule and generating over, you’ll notice that your entity class now calls a method named after your life-cycle event such as OnBeforeSave for instance. So to add some custom logic before this entity is saved, all a developer would have to do is to implement this method in a partial class (so it won’t get overwritten upon a future new generation) and that’s it.

If you want to see it in action, it’s actually shown in the Overview video, in the “Extend Generated Code” chapter, at 12:20 in the following video:

CodeFluent Entities Overview
  1. No comments yet.
  1. No trackbacks yet.

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s