CodedThought.Core
8.0.1.11
See the version list below for details.
dotnet add package CodedThought.Core --version 8.0.1.11
NuGet\Install-Package CodedThought.Core -Version 8.0.1.11
<PackageReference Include="CodedThought.Core" Version="8.0.1.11" />
paket add CodedThought.Core --version 8.0.1.11
#r "nuget: CodedThought.Core, 8.0.1.11"
// Install CodedThought.Core as a Cake Addin #addin nuget:?package=CodedThought.Core&version=8.0.1.11 // Install CodedThought.Core as a Cake Tool #tool nuget:?package=CodedThought.Core&version=8.0.1.11
CodedThough.Core
A Custom ORM and .NET Utility Codebase
The CodedThought.Core library is a custom entity framework used to primarily abstract the database away from consuming components or clients. It has many other useful aspects:
- Sql Server, Oracle, and REST Api Data Providers
- Email and Address Parsing
- Excel Import and Generation
- Extensions
- LDAP API Integrations
- SFTP and cURL Integration
- ASP.NET WebControls
- US Holiday Calculator
- Validation Engine with highly customizable expression based language
Installation
CodedThought.Core requires several package dependencies, but these are easly done using the existing NuGet packages referenced.Installation is simply done by referencing the CodedThought.Core and Configuraion libraries and any of the source specific Core Provider libraries like CodedThought.Core.Data.SqlServer.
A recommended approach to installation is by using the nuget package manager. The path to all the packages is https://nuget.pkg.github.com/erikbartlow/index.json.
Usage
Application Settings are accessed via .NET Core appsettings.json while database and/or API connection details are stored in a custom json settings file named ctSettings.json. CodedThought.Core supports environment based settings.json implementations.
Core Settings Parameters
CoreSettings/Settings
Property | Options | Description |
---|---|---|
WINFORM | boolean | The purpose of this setting is to tell the CodedThought.Core framework if it is being used in a web environment or not. The reason for this is so that the framework can cache the discovered data aware classes and associated types properly. |
ApplicationCookieName | Name of root application cookie | Provide a custom name for your application cookie. |
Connection Parameters
CoreSettings/Connections
The connections settings is an array of CoreSettings/Connections. However, only one can have the Primary key set to true or false. | Property | Data Type | Description | | ------ | ------| ------ | Name | string | Enter a unique name for the connection here. The CodedThought.Core framework supports multiple database connections on multiple platforms. | Primary | boolean | Specifies which connection the framework should use by default. | ProviderType | string |Specifies which client provider you are expecting to use with this connection. Accepted provider types: [ SqlServer | Oracle | MySql | OleDb | ApiServer ]. SqlServer is the default provider type. | DefaultSchema | string |Enter the default schema to use with this connection. Note: This feature allows the developer to create mulitple connections to the same database but pointing to different schemas within the database. This useful when setting the default schema for a database user is not possible.--The ApiServer provider does not require this | ConnectionString | string |Enter the full connection string here for the database. For Oracle connections you can enter the full TNS Names entry if necessary or just the TNSNAMES.ora entry name. For Api connection use the Url endpoint. | PoviderName | string | Enter the .NET System.Data allowed provider name for this connection. This is not a substitute for the ProviderType setting, and is only required for as long as your .NET connection requires it. The ApiServer provider does not require this. Microsoft.Data.SqlClient is the default provider name.
Data Entity Management
Custom Attributes
There are two custom attributes used by CodedThought.Core.Data.
- DataTable
- DataColumn
- ApiDataController
- ApiDataParameter
DataTable Attribute Properties
Name | Description | Options & Remarks |
---|---|---|
TableName | Physical name of the table to get, save, or delete from. | |
ViewName | Physical name of a view to get from.<br />Note: This is useful for developers when you have a particular set of data elements that need to be joined to display or report on. | |
SchemaName | Name of the database schema this entity resides in | Default is dbo |
SourceName | Gets the name of the source based on the UseView property and availability of the table and view name properties. | |
Properties | A list of all bound properties in the entity | |
Key | The specific DataColumnAttribute current set as the database key | The system currently only supports a single property to be a key and does not support. Multiple keys planned for a later release |
Sample Usage
[DataTable( tblRegions )]
[DataTable( tblRegions, vRegions )]
DataColumn Attribute Properties
Name | Description & Options | Required | |
---|---|---|---|
ColumnName | Physical name of the column in the table to get, save, or delete from. | Yes | |
IsPrimaryKey | Is this property/column the primary key in the table? true | false Default: false | Yes |
IsUpdateable | Is this property/column considered updateable? This is usually true unless it is also the primary key. true | false Default: true | No |
Size | Denotes the maximum size of data stored in the column. Note: This is only used for string based columns. | No | |
ColumnType | Specifies the System.Data.DbType associated with the column. | Yes | |
PropertyType | Used by bulk copy procedures to dynamically ascertain the class to table column type mappings. | No | |
PropertyName | Used by bulk copy procedures to dynamically ascertain the class to table column name mappings. | No | |
ExtendedPropertyType | When setting this to another classes type the developer can set a property that is of an object type rather than a simple type. This is very useful when a class property references an ENUM. Usage: typeof(MyNamespace.MyEnum) | No | |
ExtendedPropertyName | The property containing the data for the column. _Note: Only used when the ExtendedPropertyType is set and is of type Object | No | |
LoadExtendedPropertyObject | Not Implemented | No | |
OverridesInherited | true or false, When set to true causes the framework to prefer the current DataColumnAttribute over inherited properties. | No | |
AllowNulls | Not Implemented | No |
Sample Usage
// Constructor Samples
[DataColumn( name: Id, type: System.Data.Int32, isKey: true )]
[DataColumn( name: Name, type: System.Data.String, size: 20 )]
[DataColumn( name: Name, type: System.Data.String, extendedPropertyType: typeof(Country), CountryName )]
IMPORTANT: Setting the ViewName property will override any TableName value previously set for all GET routines. However, Save and Delete routines will always use the TableName value since updateable views are not always supported across database platforms.
ApiDataController Attribute Properties
Name | Description &Options | Remarks |
---|---|---|
ControllerName | The endpoint controller name where the entity can be reached. | No |
Action | The action name. | Yes |
Properties | ApiDataPrameters: List of all bound action parameters found for the entity. | No |
Key | Gets or sets the entity's key property. This is used during Api calls that typically have an id=? parameter. | No |
ClassType | typeof() | No |
ClassName | Nullable full namespace for the entity | No |
Create Data Aware classes
A key component to the CodedThought.Core.Data framework are the custom tags designed to enable the framework to learn how to communicate with your database. You can design them like any C# class, but it is key to understand that the framework is dynamically creating parameterized queries based on the custom attributes you set.
Create a Controller Class that inherits from the GenericDataStoreController with at least one constructor.
Important: The GenericDataStoreController class provides your controller with all the necessary methods for CRUD through the DataStore object. The DataStore is the derived instance of the DatabaseObject.
public DbController(IMemoryCache memoryCache, CoreConnectionString connectionString) {
// Connection to database.
DatabaseConnection cn = new DatabaseConnection( *Connection Name* );
try {
DataStore = new GenericDataStore( memoryCache, new(connectionString) );
} catch ( Exception ex ) {
throw;
}
}
Create a class with data aware properties.
using System.Data;
using CodedThought.Core.Data;
[DataTable( tblRegion )]
public class Region{
[DataColumn( name: regionId, type: System.Data.Int32, isKey: true )]
public int Id{ get; set; }
[DataColumn( name: regionName, type: System.Data.String, size: 20 )]
public string Name { get; set; }
}
Add CRUD Methods to the Controller class
public Region GetRegion( int id ){
try{
return DataStore.Get<Region>( id );
} catch {
throw;
}
}
public List<Region> GetRegions(){
try{
// The GetMultiple method requires a ParameterCollection. So to simply
// return all records we just have to pass a null ParameterCollection.
return DataStore.GetMultiple<Region>(null);
} catch {
}
}
ParameterCollection
The ParameterCollection inherits from CollectionBase and implements the IList, ICollection, IEnumerable interface.
Methods | Description & Options |
---|---|
Add | Adds a parameter to the collection. Overloads: ( IDataParameterCollection parameters ), ( ParameterCollection parameters ), ( IDataParameter parameter ) |
AddBooleanParameter() | string Column Name, boolean Value |
AddCharParameter() | string Column Name, string Value, int Size |
AddDataTimeParameter() | string Column Name, DateTime Value |
AddDoubleParameter() | string Column Name, double Value |
AddInt32Parameter() | string Column Name, int Value |
AddOutputParameter() | string Parameter Name, DBTypeSupported Return Value |
AddStringParameter() | string Column Name, string Value |
AddSubGroupParameterList() | ParameterCollection list |
AddXmlParameter() | string Column Name, string Value |
Remove() | int index |
SubParameterGroupWhereType | Using the DatabaseObject.WhereType enumerator this instructs the framework on how to handle any sub parameter groups if found.Note: Only used when the AddSubGroupParameterList() method is used. |
Load and Access appSettings.json and ctSettings.json
Using the configuration specific extension routines you can auto load the appSettings and any environment based json configurations.
Note: The name of the environment is used to locate any environment specific versions of the file. For example, if your environment is name dev then your settings file should be appsettings.dev.json.
// This is a simple extension to add the typical .NET appsettings.json file.
builder.AddAppSettingsConfiguration(Optional: IConfigurationBuilder.Environment)
// Alternatively you can use this extension to load both the typical appsettings.json as well as
// the CodedThought.Core settings file, ctsettings.json.
builder.AddCoreSettingsConfiguration(Optional: IHostEnvironment.Environment)
Add the provider specific libraries to your dependency injection
using CodedThought.Core.Extensions;
WebApplicationBuilder builder = WebApplication.CreateBuilder(args);
// Add the CodedThought.Core database type used in this project for DI.
builder.Services.AddCoreDataProvider<CodedThought.Core.Data.SqlServer.SqlServerDatabaseObject>();
builder.Services.AddCoreDataProvider<CodedThought.Core.Data.MySql.MySqlDatabaseObject>();
builder.Services.AddCoreDataProvider<CodedThought.Core.Data.OleDb.OleDbDatabaseObject>();
Product | Versions Compatible and additional computed target framework versions. |
---|---|
.NET | net8.0 is compatible. 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. |
-
net8.0
- BouncyCastle.NetCore (>= 2.2.1)
- ChoPGP.Core (>= 1.0.1.2)
- CodedThought.Core.Configuration (>= 8.0.1)
- Microsoft.Data.SqlClient (>= 5.2.2)
- Microsoft.Extensions.Caching.Abstractions (>= 8.0.0)
- Microsoft.Extensions.Caching.Memory (>= 8.0.1)
- Microsoft.Net.Http.Headers (= 2.1.14)
- SkiaSharp (>= 2.88.8)
- System.DirectoryServices (>= 8.0.0)
- System.DirectoryServices.AccountManagement (>= 8.0.1)
- System.Runtime.Caching (>= 8.0.0)
NuGet packages (10)
Showing the top 5 NuGet packages that depend on CodedThought.Core:
Package | Downloads |
---|---|
CodedThought.Core.Data.SqlServer
The CodedThought.Core.Data.SqlServer package is a custom database provider for use with Sql Server. |
|
CodedThought.Core.Data.MySql
The CodedThought.Core.Data.MySql package is a custom database provider for use with MySql Server. |
|
CodedThought.Core.Data.ApiServer
The CodedThought.Core.Data.ApiServer library is a custom REST Api Data provider for the CodedThought.Core Data Entity library. |
|
CodedThought.Core.Data.ExcelSystem
The CodedThought.Core.Data.ExcelSystem package is a custom provider for use Microsoft Excel and CSV files. |
|
CodedThought.Core.Business
The CodedThought.Core.Business library collection of usefull business focused objects. |
GitHub repositories
This package is not used by any popular GitHub repositories.
Version | Downloads | Last updated |
---|---|---|
8.0.1.25 | 37 | 12/20/2024 |
8.0.1.24 | 36 | 12/20/2024 |
8.0.1.22 | 103 | 12/9/2024 |
8.0.1.17 | 94 | 11/22/2024 |
8.0.1.11 | 87 | 11/15/2024 |
8.0.0-rc.8 | 192 | 8/29/2024 |
8.0.0-rc.7 | 100 | 7/24/2024 |
8.0.0-rc.6 | 58 | 7/24/2024 |
8.0.0-rc.5 | 44 | 7/24/2024 |
8.0.0-rc.4 | 116 | 6/13/2024 |
7.0.1.35 | 128 | 10/26/2023 |
7.0.1.34 | 214 | 10/26/2023 |
Minor fix to GenericDataStore:GetReaderValueAs(object value, Type targetType) to handle the Guid type.