GT.Core 2.5.1

dotnet add package GT.Core --version 2.5.1
NuGet\Install-Package GT.Core -Version 2.5.1
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="GT.Core" Version="2.5.1" />
For projects that support PackageReference, copy this XML node into the project file to reference the package.
paket add GT.Core --version 2.5.1
#r "nuget: GT.Core, 2.5.1"
#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 GT.Core as a Cake Addin
#addin nuget:?package=GT.Core&version=2.5.1

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

GT.Core

Base library usable for all GT projects

Data manipulation

Data manipulation has base rule - every table have to has primary key with name Id. This primary key have to be int and property Identity = yes and autoincrement start with 1 and increment counter is 1. Name of tables are in plural and start with Uppercase letter. in style CamelCase.

In object model is this table realized by interface IEntityWithIdentity. Object is named as data access object and his name is {NameInSingular}Dao. With object implemented interface IEntityWithIdentity is possible use base operations database with object implemented interface IEntityRepository<T>.

With IEntityRepository<T> is importand to write: Here is function Save to insert or update row according to unique Id. If Id is 0, then is used DB Insert otherwise DB Update. If on input is property of object 0 after save is changed to his actual Id in database. So Save and Add functions return Id after insert to input object ID property.

We can work with data in transaction. Transaction scope class has name UnitOfWork.

using (var scope = _memberContext.CreateUnitOfWork())
{
    userRepository.Save(user, scope);
    if (permission.Name == "ADMIN")
        scope.RollBack();
    else
    {
        permissionRepository.Save(permission, scope);
        scope.SaveChanges();
    }
}

For access to database we using object DataSources. This object contains list of data sources used in application. One of data sources can be used as default. Othewise is used as default first.

To know objects used in datasource are DAO object decorated by attribute EntityAttribute. This attribute has required parameter name of data table. DataSource is not required, but is is not filled, then is used default datasource.

[Entity("ShoppingCarts", "Jumaz")]

examle, with ShoppingCarts as table name and Jumaz as data source name.

For wokr with data table:
  • Create data table
CREATE TABLE [dbo].[Suppliers](
	[Id] [int] IDENTITY(1,1) NOT NULL,
	[GlobalId] [int] NOT NULL,
	[Name] [nvarchar](100) NOT NULL,
 CONSTRAINT [PK_Suppliers] PRIMARY KEY CLUSTERED 
(
	[Id] ASC
)WITH (PAD_INDEX = OFF, STATISTICS_NORECOMPUTE = OFF, IGNORE_DUP_KEY = OFF, ALLOW_ROW_LOCKS = ON, ALLOW_PAGE_LOCKS = ON) ON [PRIMARY]
) ON [PRIMARY]
  • Create datasource connection
 DataSources ds = new DataSources();
ds.DataSourceList.Add(key: "Jumaz", value: new DataSourceConnection() { ConnectionDefinition = @"Password=password;Persist Security Info=True;User ID=useName;Initial Catalog=Nazov_Db;Data Source=SERVER" });
  • Create Dao object
[Entity("Suppliers", "Jumaz")]
    public class SupplierDao : IEntityWithIdentity
    {
        public int Id { get; set; }

        public string Name { get; set; }
    }
  • realize interface IEntityRepository<T>. In standard way using DapperRepository<T> from library GT.Core.Repositories.Dapper
  • use standard methods as for example
_suplierRepository.GetAll();
...
_suplierRepository.GetById(id);
...
_suplierRepository.Save(supplier)
...
  • or if is necessary use direct sql, then create inheritance of DataBase and create special sql command.
  • Here we standard use library Dapper.
        public IEnumerable<CarModel> GetCarModels()
        {
            SqlBuilder builder = new SqlBuilder();

            var sqlTemp = builder.AddTemplate($"SELECT MasterEuroCode as EuroCode, Model as FullModelName, CategoryId, Vintage, Info FROM Articles p /**groupby**/");
            builder.GroupBy($"MasterEuroCode, Model, CategoryId, Vintage, Info");
            return this.WithConnection((conn) =>
            {
                return conn.Query<CarModel>(sqlTemp.RawSql, sqlTemp.Parameters);
            });
        }
Mapping

We don't use any automappers as automapper or similars

In namespace GT.Core.Extensions are base classes for manual mapping.

ISingleMapper - Interface for simple object mapping

public class MembersMapper : 
        ISimpleMapper<User, UserDao>, 
        ISimpleMapper<Module, ModuleDao>, 
        ISimpleMapper<Permission,PermissionDao>
    {
        public User Map(UserDao source)
        {
            if (source == null)
                return null;
            return new User
            {
                Email = source.Email,
                UserName = source.UserName,
                Id = source.Id
            };
        }
    }

IMultipleMapper - Interface for complex object mapping. Is not used so offen

MapNull - is extension for null or default result if source object is null.

return source.MapNull(() => new OfferDao
    {
        Id = Offers.GetIdByGlobalId(source.GlobalId),
        ArticleId = Articles.GetIdByGlobalId(source.GlobalArticleId, false),
        EuroCode = source.EuroCode,
        GlobalId = source.GlobalId,
        Info = source.Info,
        IsActive = source.IsActive,
        Model = source.Model,
        SupplierId = Suppliers.GetIdByGlobalId(source.GlobalSupplierId, false)
    });

MapMany - Map list of ISingleMapper or IMultipleMapper

Synchronization - GlobalId

For synchonization between two systems is needed use synchronization ked. In our case we use GlobalId and we have interface IGlobalEntity<T> to work with object.

Project Folders

Composition
  • Here is only importat class IGTLogger
Configurations
  • Here are defined rules to work with configurations. Here are base Dao objects. most important is IConfigurationService. Interface define methods to use configuration

Release notes

VERSION 2.2.0

tgalik 24.10.2017 09:22
  • doplnena sluzba EntityService. Sluzba ponuka zakladne moznosti editacie tabulky. Pouzitelne hlavne pre jednoduche entity a tiez ako rodicovska trieda pre obsluhu zlozitejsich entit

VERSION 2.2.1

tgalik 24.10.2017 10:08
  • vyradenie nepotrebneho parametra

VERSION 2.2.6

tgalik 24.10.2017 12:21
  • zmena private properties na public
  • doplenenie metody GetById - vrati podla Idecka
  • Vytvorenie interface IEntityService
  • Ukladanie rozdelene na pridavanie a zmenu Add & Updated
  • Objekt Add vracia vstupny objekt lebo ho meni (doplni mu realne Id) - toto asi prerobim cez ref

VERSION 2.2.7

tgalik 02.11.2017 12:21
  • nic len probme s nugetom

VERSION 2.3.0

mgluch 06.12.2017 15:46
  • pridaná metóda na odšifrovanie hesla

VERSION 2.4.0

tgalik 15.12.2017 09:36
  • pridany IFAcador - interface pre objekt, kde je jeden hlavny objekt vo facade
  • zmeneny servis EntityRepository. Pri nom uz neuvazujem o tom ze bude existovat samostatny business objekt. Za bussines objekt sa bude povazovat Dao objekt. Uvazujem o tom, ze ci je konocka Dao v tom pripade nalezita, kedze sa dao obkejt stava sucasne bussines objektom
  • pridany solution file v adresari sln.

VERSION 2.4.2

tgalik 06.02.2018 09:56
  • translated to english language
  • cleaning some part of code
  • obsoleting unused code
  • renaming configuation DAO object according to rule
  • SignInManager, SecurePasswordHasher moved to GT.Members

VERSION 2.4.3

tgalik 06.02.2018 15:59
  • Configuration realizatiom moved to Gt.Services.Configuration

VERSION 2.4.4

tgalik 06.02.2018 16:39
  • Change IConfiguratioService

VERSION 2.4.5

tgalik 08.02.2018 13:28

-* Added MapEntityService

VERSION 2.4.6

tgalik 08.02.2018 13:40

-* Changed namespace for MapEntityService

VERSION 2.5.0

tgalik 08.02.2018 13:40

-* Added IEntityService. EntityServiceImplement IEntityService

VERSION 2.5.1

tgalik 09.02.2018 13:40

-* removed MapEntityService z namespce module. Was duplicite

Product Compatible and additional computed target framework versions.
.NET net5.0 was computed.  net5.0-windows was computed.  net6.0 was computed.  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. 
.NET Core netcoreapp1.0 was computed.  netcoreapp1.1 was computed.  netcoreapp2.0 was computed.  netcoreapp2.1 was computed.  netcoreapp2.2 was computed.  netcoreapp3.0 was computed.  netcoreapp3.1 was computed. 
.NET Standard netstandard1.3 is compatible.  netstandard1.4 was computed.  netstandard1.5 was computed.  netstandard1.6 was computed.  netstandard2.0 was computed.  netstandard2.1 was computed. 
.NET Framework net452 is compatible.  net46 was computed.  net461 was computed.  net462 was computed.  net463 was computed.  net47 was computed.  net471 was computed.  net472 was computed.  net48 was computed.  net481 was computed. 
MonoAndroid monoandroid was computed. 
MonoMac monomac was computed. 
MonoTouch monotouch was computed. 
Tizen tizen30 was computed.  tizen40 was computed.  tizen60 was computed. 
Universal Windows Platform uap was computed.  uap10.0 was computed. 
Xamarin.iOS xamarinios was computed. 
Xamarin.Mac xamarinmac was computed. 
Xamarin.TVOS xamarintvos was computed. 
Xamarin.WatchOS xamarinwatchos was computed. 
Compatible target framework(s)
Included target framework(s) (in package)
Learn more about Target Frameworks and .NET Standard.

NuGet packages (3)

Showing the top 3 NuGet packages that depend on GT.Core:

Package Downloads
GT.Core.Repositories.Dapper

Package Description

GT.API.Core

Base library to work with API. Library has base classes to create API, use permissions in API, result object standard, logging and similars.

GT.Services.Configuration

Sluzba pre pracu s configuraciami

GitHub repositories

This package is not used by any popular GitHub repositories.

Version Downloads Last updated
2.5.1 1,901 3/29/2018