KLO128.D3ORM.Common

Dependencies: KLO128.D3ORM.Common.Abstract

./

D3BaseContext : ID3Context

  • Proxy abstract class that contains basic props and functionality for mapping entity names and relations to be able to handle queries. 
  • Implements ID3Context

namespace KLO128.D3ORM.Common
{
    public abstract class D3BaseContext : ID3Context
}

D3BaseSpecification : ISpecification

  • Proxy abstract class that contains basic declarations that are used and implemented in D3CoreSpecification and D3Specification. 

namespace KLO128.D3ORM.Common
{
    public abstract class D3BaseSpecification : ISpecification
}

D3Specification

  • Helper static class that contains instantiating and building functions for D3Specifications to be used at infrastructure side... 

namespace KLO128.D3ORM.Common
{
    public static class D3Specification
}

# Member Name Return Type Description Default Value
propHelperInitializedpublicIndicates if the SpecHelper is initialized.
propSpecHelperpublicDO NOT use externally. Internal static helper used to handle this tool functions. Instantiated with ID3Context instantiation.
propThrowWhenExpectedJoinNotSuccessfulpublicIndicates if to throw an exception if a try of appending a join was not successful. True by default.
funcBuildSQL(..)stringBuilds and gets the SQL using the parameters for the filter.
funcCreate<TEntity>(..)ISpecification<TEntity>Creates a new instance of ISpecification<TEntity>
funcCreate<TEntity, TParent>(..)ISpecification<TEntity>Creates a new instance of ISpecification<TEntity> which is prepared to be appended to a parent specification only through the propToIncludeOnly (in case of more references from a single table).
funcCreate<TInverseRoot, TResult>(..)ISpecification<TResult>Creates a new instance of ISpecification<TResult> which must be on the very left side of future joining (this specification cannot be appended to some parent one). The query result should be selected as List<TResult>The top query context is of type TInverseRoot
funcPreBuild<TEntity>(..)ISpecification<TEntity>Prebuilds the specification in order to cache SQL part strings for building a final query.
funcRemoveFilterItems<TEntity, THolder>(..)ISpecification<TEntity>Returns a new specification with cloned filter created from that specification and removes all the filter items containing the specified filterProp
funcRemoveSortItem<TEntity, THolder>(..)ISpecification<TEntity>Returns a new specification with cloned sort context created from that specification and removes all the sort items containing the specified sortProp

ID3Context


namespace KLO128.D3ORM.Common
{
    public interface ID3Context
}

# Member Name Return Type Description Default Value
propDatabaseTypeDatabaseTypeThe database system this context is created for.
propDateFormatstringDatabase System Date Format: yyyy-MM-dd is the default value.
propDbIdColumnFormatstringName Format of Id Columns
propDtoPatternFormatstringDTO pattern supporting regular expression syntax. Must contain a placeholder for an entity name: {0}
propEntityIdPropFormatstringName Format of Id Properties
propEntityMappingsDictionary<Type, The dictionary (EntityType -> EntityMapping) for a quick indexed access to EntityMapping of each type.
propEntitiesNameSpacestringThe namespace of the Entities
propExceptionalDbColumnNamesDictionary<string, Defines non-standard property -> column name mappings, which cannot be guessed. I.e.: GUIDExpirationDate would be converted from camel case into MySQL or Oracle name as: g_u_i_d_expiration_date. Important also for other DbSystems using camel case names if a column or table name is not the same as a property name.
propIdefStartcharThe start identifier character, typically for MySQL: ` or for MSSQL, SQLite: [ | | | **prop** | **IdefEnd** | `char` | The end identifier character, typically for MySQL: ` or for MSSQL, SQLite: ]
propNotEqualOperatorstringThe target database not equal operator string - it differs across database systems: != or <>
propNotFunctionstring?Specifies NOT(condition) function name. If null then (condition) = 0 is used.
propOtherModelNamespacespublicDefines other namespaces (other than query root's namespace) where to find entity or DTO.
propUseAutoIncrementboolIndicates if to skip populating of an id primary key property (if it is populated by itself in the database using the auto-increment principle).
propUseFullIdOrderByboolIndicates if to include all primary keys into ORDER BY expression even if there are no other "many to one" or one-to-many sorts from a current one-to-many context select group till the end of the select.
funcConcatDbName(..)stringConcatenates the text (usual usage: asPrefix == true) to the database dbName with persistence of naming conventions and identifier start-end quotes.
funcConvertsDbValue(..)object?Converts the database value into the target propertyType
funcCreateAnonymousConnection(..)IDbConnecttionCreates an anonymous connection outside of any IoC container - useful for asynchronous bulk operations, which needs to continue even if request ends.
funcGetDbNameQuoted(..)stringGets a database name from the name including IdefStart and IdefEnd chars.
funcGetEntityNameFromDTO(..)string?Gets the entity name from the dtoName
funcGetIdPropName(..)stringGets the id property name from the entityName
funcGetLastInsertedRowIdCommandText(..)stringRetrieves a database script for obtaining the last inserted row id.
funcIsEntityIdProp(..)boolDetermines if the propName is an id like property name.
funcTryGetEntityNameFromIdProp(..)string?If the propName is id like, returns its entity name, otherwise returns null.

./Extensions

Data Reading Extensions


namespace KLO128.D3ORM.Common.Extensions
{
    public static class DataReadingExtensions
}

# Member Name Return Type Description Default Value
funcAggCompute<TEntityOrDTO, TResult>(..)List<TResult>Executes computing aggregation functions according to the cmdBatch(2 commands are generated from a specification if the skip and take option is used.) Returns a list of TResult containing the property names and the structure specified by the cmdBatch
funcAggCompute<TResult>(..)List<TResult>Executes computing aggregation functions according to the sqlAdapterReturns a list of TResult containing the property names and the structure specified by the sqlAdapter
funcAggSelect<TEntityOrDTO, TResult>(..)List<TResult>Queries the database by the cmdBatch(2 commands are generated from a specification if the skip and take option is used.) Returns a full object tree (aggregated) list of TResult as a result.
funcAggSelect<TResult>(..)List<TResult>Queries the database by the sqlAdapterReturns a full object tree (aggregated) list of TResult as a result.

DbConnection Extensions


namespace KLO128.D3ORM.Common.Extensions
{
    public static class DbConectionExtensions
}

# Member Name Return Type Description Default Value
funcAttachTransactionvoidAttaches connection's transaction to the cmd if accessible. MSSQL requires it.
funcExecuteCommandvoidOpens the connection if not opened, creates a non-query command using cmdText and parsexecutes the command and disposes the command.
funcExecuteDbStoredCommandvoidExecutes a command as a stored procedure using cmdText and parametersThe connection is opened if not have been and the command is disposed after finishing the work.
funcOpenIfNotvoidOpens the connection if not opened.

./Impl

  • Contains internal helpers and implementations of repositories, specifications and base logic of D3Contexts... 


namespace KLO128.D3ORM.Common.Impl
{
    public class D3SpecificationWithParams<TEntity> : D3SpecificationWithParams, ISpecification<TEntity>, ISpecificationWithParams<TEntity> where TEntity : class
    {
    }

    public abstract class D3SpecificationWithParams
    {
    }

    public class D3Specification<TEntity> : D3CoreSpecification, ISpecification<TEntity> where TEntity : class
    {
    }

    public abstract class D3CoreSpecification : D3BaseSpecification
    {
    }

    public class D3AggRootRepository<TEntity> : D3CommonRepository<TEntity>, IAggRootRepository<TEntity> where TEntity : class, new()
    {
    }

    public class D3CommonRepository<TEntity> : ICommonRepository<TEntity> where TEntity : class, new()
    {
    }
    ...
}

 

./Impl.Extensions

  • Contains internal extension utilities and also public functions for retrieving CRUD scripts used in the repositories. 


namespace KLO128.D3ORM.Common.Impl.Extensions
{
    public static class D3QueryHelper
    {
        public static string FindByIdQuery<TId>(this ID3Context d3Context, EntityMapping entityMap, TId id);

        public static string? GetBulkUpdateScript<TEntity>(this ID3Context d3Context, ISpecification<TEntity> specification, params Tuple<LambdaExpression, object?>[] propValues) where TEntity : class, new();

        public static string? GetBulkDeleteScript<TEntity>(this ID3Context d3Context, ISpecification<TEntity> specification) where TEntity : class, new();

        public static string? GetDeleteScript<TEntity>(this ID3Context d3Context, TEntity entity);

        public static string? GetInsertScript<TEntity>(this ID3Context d3Context, TEntity entity);

        public static string? GetUpdateScript<TEntity>(this ID3Context d3Context, TEntity entity);

        public static string? GetUpdateScript<TEntity>(this ID3Context d3Context, TEntity entity, bool setValues, Tuple<LambdaExpression, object?>[] propValues);

        ...
    }

    ...
}

./Models

Operator


namespace KLO128.D3ORM.Common.Models
{
    public enum Operator
}

# Member Name Description
NONE = 0 No Operator
IN = 1 Item IN Collection or IN Selection Operator
NOT_IN = 2 Item NOT IN Collection or NOT IN Selection Operator
EQUALS = 3 '=' Operator
NOTEQUAL = 4 '!=' or '<>' Operator (Depends on database system.)
GREATER_THAN = 5 '>' Operator
LESS_THAN = 6 '<' Operator
GREATER_THAN_OR_EQUAL = 7 '>=' Operator
LESS_THAN_OR_EQUAL = 18 '<=' Operator
LIKE = 9 LIKE Operator
NOT_LIKE = 10 NOT LIKE Operator
AND = 16 Logical AND Operator
OR = 32 Logical OR Operator
DuplicitAnd = 64 Duplicit references will be appended by the AND operator (OR is default).
DuplicitOr = 128 Duplicit references will be appended by the OR operator - this is the default option (if no other duplicit operator set).
AndDuplicitAnd = 16 | 64
AndDuplicitOr = 16 | 128
OrDuplicitOr = 32 | 128
OrDuplicitAnd = 32 | 64