MarimerLLC / cslaforum

Discussion forum for CSLA .NET
https://cslanet.com
Other
31 stars 6 forks source link

Code generator tools? #609

Open inforlance opened 6 years ago

inforlance commented 6 years ago

Hello,

I'm using csla since 4 months now and i was wondering if there were code generators you could advice me?

The most important would be to generate the business layer based on an existing datalayer. So maybe some specific tools would be more suitable than another one for this use.

Regards

tfreitasleal commented 6 years ago

Hi,

That's exactly what CslaGenFork does:

Some months/years after your project is alive, users will ask for more features. Just add the properties and classes you need and regenerate the code.

Important notes

1) CslaGenFork generates partial classes, so you can isolate your custom code on a separate file (or files) that the generator won't override.

2) CslaGenFork generated code has several extension points, mainly partial methods.
Partial methods may or may not be implemented. When they are implemented, they are used as you would expect. If they are not implemented, at compile time they are ignored.
Partial methods implementation should be done on a separate file, that's generated only once, so you don't have to SVN/GitHub Revert this file after every code regeneration.

3) Although Stored Procedures for SQL Server are generated, you can choose to code some or all SQL commands inline. In this case, you can use the generated Stored Procedures as a starting point.

4) Although SQL Server is preferred, code generation can target other database engines.
The generated code will use the correct namespace, Connection and Command methods, as well as the correct data types for each implementation. Anyway this is configurable in the UI, in case you need to change something or add a new DbProvider.
For these new DbProviders, there is no support for generating the correct SQL commands. You can use the SQL Server Stored Procedures as a starting point. See the list of existing providers below.

Engine NuGet package
Oracle Oracle.ManagedDataAccess
Firebird FirebirdSql.Data.FirebirdClient
PostgreSQL Npgsql
MySQL MySql.Data
SQLite System.Data.SQLite.Core

Final note

As CslaGenFork does most if not all of my SQL coding for me, I don't see there is any advantage on using anything other than ADO.NET. For me ADO.NET is simpler than EF or Dapper, or whatever, because I don't see SQL code at all, except when I have to do some super-extra complicated query that would have to be hand coded on any techonology.

Furthermore, every other database techonology is build on top of ADO.NET. So it won't be faster than ADO.NET for sure.