com.techienetworks.framework
1.3.3
See the version list below for details.
dotnet add package com.techienetworks.framework --version 1.3.3
NuGet\Install-Package com.techienetworks.framework -Version 1.3.3
<PackageReference Include="com.techienetworks.framework" Version="1.3.3" />
paket add com.techienetworks.framework --version 1.3.3
#r "nuget: com.techienetworks.framework, 1.3.3"
// Install com.techienetworks.framework as a Cake Addin #addin nuget:?package=com.techienetworks.framework&version=1.3.3 // Install com.techienetworks.framework as a Cake Tool #tool nuget:?package=com.techienetworks.framework&version=1.3.3
TNFramework
A simple, effective, object-oriented ORM.
Getting Started
The Techie Framework is designed to be used as a platform to get your .net enterprise application off the group and running, fast. Currently, only SQL server is supported with c# output.
The "Framework" part of this framework is simple the data access layer and the business object definition. Everything else is just simple generated code with a few utility functions to make my coding life easier and faster.
Prerequisites
The prerequisite to starting with the Techie Framework is a well defined, well connected SQL server database design. There are a few rules and features of the framework that will help you along the way.
Database Design
Use the following loosly defined rules to start using the framework.
Table Names
All table names should be singular, with or without a prefix. Example table names are:
User
Address
Customer
Order
...
with a prefix
TNUser
TNAddress
TNCustomer
Primary Keys
All tables must have a primary key, either varchar, int, bigint or uniqueidentifier. Running the code generator against a table without a primary key will yield weird results. This field name ideally should be the table name + "ID"
OrderID
UserID
AddressID
Foreign Keys
Tables linked via foreign key must have the primary key in the field name to create an object link. For example, a link from an "Order" table to an "Address" table would look like:
ShippingAddressID
Indexes
Tables with an index will allow the generator to create stored procedures that can be used with those indexes. For example, an Order table with a column called CustomerID which is a FK and, has an Index would create a stored procedure called
getOrderByCustomerID
If multiple columns are present in an index, then the stored procedure would be
getOrderByFirstColumnSecondColumn
Cross References
Cross reference tables should always have an Primary Key, and end with the verb "Xref". These tables are ignored by the generator and only stored procedures are created for you to define the cross reference manually.
Type Codes
Columns that end with the verb "TypeID" will cause the generator to spit out Enum files so that an actual enumerator can be used in your code. However, if a table exists with that type then this will not occur as it will be assumed that the types will be defined by data instead.
StatusCodes
By adding a column names "StatusCodeID", the generator will spit out a Status enum for you to define the status in code. a column called StatusCodeID in an Order table will yield the enumn OrderStatus and create the enum property on the order object.
DateCreated
By adding a column named "DateCreated" will tell the generator to default the field in the class to DateTime.Now.
LastUpdated
Same as DateCreated, except this column will always default to DateTime.Now when a save is called on the object.
Inheritance
This is an experimental feature. By defining a foreign key column with a suffix of IID, you tell the framework that the object is derived from another object. The intention of this is to allow for inheritance of objects with data layer persistance.
For example an "Transaction" table might be used for financial history, with a transactionType column that defines what kind of transaction it was - such as an payment or a refund. By creating a "Refund" table that has a column "TransactionIID" the class generated for the Refund will derive from the Transaction table.
Installing
A step by step series of examples that tell you how to get a development env running
Say what the step will be
Give the example
And repeat
until finished
End with an example of getting some data out of the system or using it for a little demo
Code Generation
The Techie.Tools.CodeGenerator object is the class to use to invoke generation of objects from a datable. Typicall this would look something like
public static void Main()
{
CodeGenerator codeGenerator = new CodeGenerator();
codeGenerator.ConnectionString = "Server=<SOMESERVER>;Database=<SOMEDATABASE>;Integrated Security=true";
codeGenerator.OutputPath = "c:\\temp";
codeGenerator.ShouldCreateProcedures = true;
codeGenerator.TargetNamespace = "Techie.ApplicationName";
codeGenerator.Author = "Jaysam Thanki";
codeGenerator.Company = "Techie Networks";
codeGenerator.Log += CodeGenerator_Log;
codeGenerator.Generate();
}
private static void CodeGenerator_Log(string message)
{
Console.WriteLine(message);
}
Make sure your connection string has a user that has permissions to read and write to the database. Only stored procedures will be created, if ShouldCreateProcedures is set to true.
Output
The Code Generator spits out 5 folders.
BaseClasses
The BaseClasses folder generates classes that you simply copy to your Visual Studio project, and forget. Do not modify these files as subsequent future generations would yield new files that would override these files.
UserClasses
The UserClasses folder generates classes ready for you to put your real business logic into, you should copy these files ONCE to your project, and then make modifications to them as needed.
TypeCodes
The TypeCodes folder generates enumerations for your type codes ready for population. You should copy these files ONCE to your project, and then make modifications to them as needed.
StatusCodes
The StatusCodes folder generates enumerations for your type codes ready for population. You should copy these files ONCE to your project, and then make modifications to them as needed.
Database
Individual files are created for each stored procedure, and a single Create.sql for all of them. If you have a change process you may want to include the create.sql for each build/deployment to ensure the correct procedures are in the system
Business Object Class
The Techie.BusinessObject class is the heart of the system. Here are a few things you can use from it
Create a custom constructor
Imagine a "User" class, and you want to look up a user by their email address rather than their Primary Key ID.
public User(string emailAddress)
: base()
{
IDbCommand command = this.MakeCommand("getUserByEmailAddress");
this.AddParam(command, "@EmailAddress", DbType.String, emailAddress);
this.PopulateObject(command);
}
In just three lines, you can return an object by using new User("junk@techie.org") that is fully populated and ready to go. If the user does not exist with that email, the constructor simply returns an empty object, so be sure to check for a UserID>0 or UserId != Guid.Empty depending upon how your PK's are defined.
Logging
Each derived class gets its own Log4Net object, so simply use Log.Whatever wherever you need logging.
ToJson
Each derived class has the option to output a Json of itself using the ToJson method
GetDifferences
This method takes in a destination object and returns a string formatted with the difference between itself and the object in the parameter.
DataSource
You may run into a situation whereby the object being created is pysically stored in a seperate database, such as image binaries or other large blobs you do not want to pollute your production data. By specifying the datasource in the generator the classes will be Decorated with a [DataSouce("CONNECTIONSTRINGKEY")] attribute so that the data access layer knows where to get/set data.
Contact
Please contact me via www.techienetworks.com if you require assistance in getting this going, or if you have a project that needs worked on using TNFramework.
Product | Versions Compatible and additional computed target framework versions. |
---|---|
.NET | net6.0 is compatible. net6.0-android was computed. net6.0-ios was computed. net6.0-maccatalyst was computed. net6.0-macos was computed. net6.0-tvos was computed. net6.0-windows was computed. net7.0 was computed. net7.0-android was computed. net7.0-ios was computed. net7.0-maccatalyst was computed. net7.0-macos was computed. net7.0-tvos was computed. net7.0-windows was computed. net8.0 was computed. net8.0-android was computed. net8.0-browser was computed. net8.0-ios was computed. net8.0-maccatalyst was computed. net8.0-macos was computed. net8.0-tvos was computed. net8.0-windows was computed. |
-
net6.0
- log4net (>= 2.0.15)
- Microsoft.Data.SqlClient (>= 5.1.4)
- Microsoft.Extensions.Configuration (>= 7.0.0)
- Microsoft.Extensions.Configuration.Json (>= 7.0.0)
- Microsoft.SqlServer.Types (>= 160.1000.6)
- Newtonsoft.Json (>= 13.0.3)
- System.Json (>= 4.7.1)
NuGet packages
This package is not used by any NuGet packages.
GitHub repositories
This package is not used by any popular GitHub repositories.
Version | Downloads | Last updated |
---|---|---|
1.3.6 | 211 | 10/8/2024 |
1.3.5 | 86 | 8/2/2024 |
1.3.4 | 409 | 7/5/2024 |
1.3.3 | 116 | 6/11/2024 |
1.3.1 | 1,455 | 10/19/2023 |
1.3.0 | 153 | 10/16/2023 |
1.2.11 | 1,023 | 10/19/2023 |
1.2.10 | 183 | 10/10/2023 |
1.2.9 | 307 | 6/23/2023 |
1.2.8 | 202 | 6/16/2023 |
1.2.7 | 192 | 6/16/2023 |
1.2.6 | 538 | 5/18/2023 |
1.2.5 | 437 | 11/11/2022 |
1.2.4 | 1,070 | 10/6/2022 |
1.2.3 | 550 | 9/13/2022 |
1.2.2 | 1,205 | 11/9/2021 |
1.2.1 | 401 | 7/23/2021 |
1.2.0 | 543 | 6/4/2021 |
1.1.8 | 1,029 | 11/10/2021 |
1.1.7 | 407 | 11/10/2021 |
1.1.6 | 404 | 11/10/2021 |
1.1.5 | 1,914 | 12/18/2019 |
1.1.4 | 680 | 4/19/2019 |
1.1.3 | 660 | 3/11/2019 |
1.1.2 | 678 | 3/7/2019 |
1.1.1 | 738 | 2/18/2019 |
1.1.0 | 731 | 2/17/2019 |
1.0.0 | 715 | 2/5/2019 |