CodedThought.Core 7.0.1.35

There is a newer prerelease version of this package available.
See the version list below for details.
dotnet add package CodedThought.Core --version 7.0.1.35
NuGet\Install-Package CodedThought.Core -Version 7.0.1.35
This command is intended to be used within the Package Manager Console in Visual Studio, as it uses the NuGet module's version of Install-Package.
<PackageReference Include="CodedThought.Core" Version="7.0.1.35" />
For projects that support PackageReference, copy this XML node into the project file to reference the package.
paket add CodedThought.Core --version 7.0.1.35
#r "nuget: CodedThought.Core, 7.0.1.35"
#r directive can be used in F# Interactive and Polyglot Notebooks. Copy this into the interactive tool or source code of the script to reference the package.
// Install CodedThought.Core as a Cake Addin
#addin nuget:?package=CodedThought.Core&version=7.0.1.35

// Install CodedThought.Core as a Cake Tool
#tool nuget:?package=CodedThought.Core&version=7.0.1.35

CodedThough.Core

A Custom Entity Framework and .NET Utility Codebase

Build Status 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.

ctsettings

Core Settings Parameters

CoreSettings/Settings

Property Options Description
WINFORM true | false 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|false. | Property | Options | ------ | ------ | Name | string Enter a unique name for the connection here. The CodedThought.Core framework supports multiple database connections on multiple platforms. | | Primary | true|false Specifies which connection the framework should use by default. | | ProviderType | 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 | 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 | 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 GET|SET Physical name of the table to get, save, or delete from.
ViewName GET|SET 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 GET|SET Name of the database schema this entity resides in Default is dbo
SourceName GET Gets the name of the source based on the UseView property and availability of the table and view name properties.
Properties GET A list of all bound properties in the entity
Key GET 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 <br />Default: false Yes
IsUpdateable Is this property/column considered updateable? This is usually true unless it is also the primary key. true | false <br />Default: true No
Size Denotes the maximum size of data stored in the column.<br />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.<br />Usage: typeof(MyNamespace.MyEnum) No
ExtendedPropertyName The property containing the data for the column.<br />_Note: Only used when the ExtendedPropertyType is set and is of type Object No
LoadExtendedPropertyObject true|false Not Implemented No
OverridesInherited true|false, When set to true causes the framework to prefer the current DataColumnAttribute over inherited properties. No
AllowNulls Not Implemented
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 string: The endpoint controller name where the entity can be reached. No
Action string: The action name. Yes
Properties GET|SET ApiDataPrameters: List of all bound action parameters found for the entity. No
Key GET|SET true|false: Gets or sets the entity's key property. This is used during Api calls that typicall have an id=? parameter. No
ClassType GET|SET typeof()
ClassName GET|SET string: Nullable full namespace for the entity
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 class DBController : GenericDataStoreController {
    
    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: <ul><li>( IDataParameterCollection parameters )</li><li>( ParameterCollection parameters )</li><li>( IDataParameter parameter )</li></ul>
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.<br /> 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.

builder.AddAppSettingsConfiguration(Optional: IConfigurationBuilder.Environment)
builder.AddCoreSettingsConfiguration(Optional: IHostEnvironment.Environment)
Product 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. 
Compatible target framework(s)
Included target framework(s) (in package)
Learn more about Target Frameworks and .NET Standard.

NuGet packages (7)

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.Business

The CodedThought.Core.Business library collection of usefull business focused objects.

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.Data.Oracle

The CodedThought.Core.Data.Oracle package is a custom database provider for use with Oracle Server.

GitHub repositories

This package is not used by any popular GitHub repositories.

Version Downloads Last updated
8.0.0-alpha-4 41 4/25/2024
8.0.0-alpha-3 43 4/25/2024
8.0.0-alpha 83 4/1/2024
7.0.1.35 96 10/26/2023
7.0.1.34 149 10/26/2023