Solution.Framework.Repository
8.0.0
dotnet add package Solution.Framework.Repository --version 8.0.0
NuGet\Install-Package Solution.Framework.Repository -Version 8.0.0
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="Solution.Framework.Repository" Version="8.0.0" />
For projects that support PackageReference, copy this XML node into the project file to reference the package.
paket add Solution.Framework.Repository --version 8.0.0
The NuGet Team does not provide support for this client. Please contact its maintainers for support.
#r "nuget: Solution.Framework.Repository, 8.0.0"
#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 Solution.Framework.Repository as a Cake Addin #addin nuget:?package=Solution.Framework.Repository&version=8.0.0 // Install Solution.Framework.Repository as a Cake Tool #tool nuget:?package=Solution.Framework.Repository&version=8.0.0
The NuGet Team does not provide support for this client. Please contact its maintainers for support.
Repository
Repository framework to access database.
This Framework uses the features of Solution.Framework.Json, Solution.Framework.Logger., Solution.Framework.Notifier and Solution.Framework.Security
All methods only return notifications and not exceptions.
All parameters contextName and eventName is [CallerFilePath] and [CallerMemberName] respectively
DataAnnotations
Sample code
StringRegex (regex string validation)
public class Client
{
public string Name { get; set; }
[StringRegex("\d{2}-\d{2}-\d{4}")]
public string ExpirationDate { get; set; }
}
Sample code
CnpjCpf (CNPJ and CPF validation)
public class Client
{
public string Name { get; set; }
[CnpjCpf]
public string CnpjCpf { get; set; }
}
Classes
Sample code
Context
using ConsoleApp.Repository.EntityFrameworks.TestDB.Models;
using Microsoft.EntityFrameworkCore;
namespace ConsoleApp.Repository.EntityFrameworks.TestDB.Contexts
{
public class TestDBContext : DbContext
{
public TestDBContext(DbContextOptions<TestDBContext> options) : base(options) { }
public DbSet<Users> Users { get; set; }
public DbSet<Posts> Posts { get; set; }
}
}
Sample code
Models
using Solution.Framework.Repository.Models;
using System.ComponentModel.DataAnnotations;
namespace ConsoleApp.Repository.EntityFrameworks.TestDB.Models
{
public class Posts : ModelBase
{
[Key]
public int PostId { get; set; }
public int UserId { get; set; }
public string Content { get; set; }
public Users User { get; set; }
}
}
using Solution.Framework.Repository.Models;
using System.Collections.Generic;
using System.ComponentModel.DataAnnotations;
namespace ConsoleApp.Repository.EntityFrameworks.TestDB.Models
{
public class Users : ModelBase
{
[Key]
public int UserId { get; set; }
public string FirstName { get; set; }
public string LastName { get; set; }
public List<Posts> Posts { get; set; }
}
}
Sample code
ViewModels
using System.ComponentModel.DataAnnotations;
namespace ConsoleApp.Repository.ViewModels
{
public class PostsViewModel
{
[Key]
public int PostId { get; set; }
public int UserId { get; set; }
public string Content { get; set; }
public UsersViewModel User { get; set; }
}
}
using System.Collections.Generic;
using System.ComponentModel.DataAnnotations;
namespace ConsoleApp.Repository.ViewModels
{
public class UsersViewModel
{
[Key]
public int UserId { get; set; }
public string FirstName { get; set; }
public string LastName { get; set; }
public List<PostsViewModel> Posts { get; set; }
}
}
DataLayerConfiguration
Properties
public ConnectionData ConnectionData { get; set; }
public LogTypeEnum LogType { get; set; }
public string UserNameLog { get; set; }
Method
new DataLayerConfiguration(<connectionData>, <logType>, "<userNameLog>")
ConnectionData
Properties
public IConfiguration Configuration { get; set; }
public IUserAuthetication? UserAuthetication { get; set; }
public TypeDBEnum TypeDB { get; set; }
public SqlServerConnectionString? SqlServer { get; set; }
public OracleConnectionString? Oracle { get; set; }
public MySqlConnectionString? MySql { get; set; }
public SqliteConnectionString? Sqlite { get; set; }
public MongoDBConnectionString? MongoDB { get; set; }
public InMemoryConnectionString? InMemory { get; set; }
public int CommandTimeoutSecond { get; set; } = 0;
public string? ConnectionString { get; set; }
Methods
new ConnectionData(<configuration>, <contextAccessor>, <userNameLog>, <logType> = LogTypeEnum.Application, <connectionName> = null, <connectTimeout> = 0, <commandTimeoutSecond> = 0, <maxRetryCount> = 0, <maxRetryDelaySecond> = 0, <validateConnection> = false, <contextName> = "", <eventName> = "")
new ConnectionData(<configuration>, <sqlServer>, <userNameLog>, <logType> = LogTypeEnum.Application, <commandTimeoutSecond> = 0, <validateConnection> = false, <contextName> = "", <eventName> = "")
new ConnectionData(<configuration>, <oracle>, <userNameLog>, <logType> = LogTypeEnum.Application, <commandTimeoutSecond> = 0, <validateConnection> = false, <contextName> = "", <eventName> = "")
new ConnectionData(<configuration>, <mySql>, <userNameLog>, <logType> = LogTypeEnum.Application, <commandTimeoutSecond> = 0, <validateConnection> = false, <contextName> = "", <eventName> = "")
new ConnectionData(<configuration>, <sqlite>, <userNameLog>, <logType> = LogTypeEnum.Application, <commandTimeoutSecond> = 0, <validateConnection> = false, <contextName> = "", <eventName> = "")
new ConnectionData(<configuration>, <mongoDB>, <userNameLog>, <logType> = LogTypeEnum.Application, <commandTimeoutSecond> = 0, <validateConnection> = false, <contextName> = "", <eventName> = "")
new ConnectionData(<configuration>, <inMemory>, <userNameLog>, <logType> = LogTypeEnum.Application, <commandTimeoutSecond> = 0, <validateConnection> = false, <contextName> = "", <eventName> = "")
new ConnectionData(<configuration>, <connectionString>, <userNameLog>, <logType> = LogTypeEnum.Application, <typeDB> = "sqlserver", <commandTimeoutSecond> = 0, <maxRetryCount> = 0, <maxRetryDelaySecond> = 0, <validateConnection> = false, <contextName> = "", <eventName> = "")
new ConnectionData(<configuration>, <connectionString>, <userNameLog>, <logType> = LogTypeEnum.Application, <typeDBEnum> = TypeDBEnum.SqlServer, <commandTimeoutSecond> = 0, <maxRetryCount> = 0, <maxRetryDelaySecond> = 0, <validateConnection> = false, <contextName> = "", <eventName> = "")
new ConnectionData(<configuration>, <userNameLog>, <logType> = LogTypeEnum.Application, <typeDB> = TypeDBEnum.SqlServer, <applicationName> = null, <serverName> = null, <database> = null, <userName> = null, <password> = null, <port> = null, <srv> = null, <tls> = null, <fileName> = null, <version> = null, <connectionTimeOut> = 0, <commandTimeOutSecond> = 0, <maxRetryCount> = 0, <maxRetryDelaySecond> = 0, <validateConnection> = false, <contextName> = "", <eventName> = "")
new ConnectionData(<configuration>, <userNameLog>, <logType> = LogTypeEnum.Application, <typeDB> = "sqlserver", <applicationName> = null, <serverName> = null, <database> = null, <userName> = null, <password> = null, <port> = null, <srv> = null, <tls> = null, <fileName> = null, <version> = null, <connectionTimeOut> = 0, <commandTimeOutSecond> = 0, <maxRetryCount> = 0, <maxRetryDelaySecond> = 0, <validateConnection> = false, <contextName> = "", <eventName> = "")
Connections
public class Connections
{
public string ConnectionName { get; set; }
public string TypeDB { get; set; }
public string ConnectionString { get; set; }
}
DapperContext
Sample Code Init
namespace ConsoleApp.Repository
{
class Program
{
static void Main(string[] args)
{
DapperContext<TestDBContext> dl = new();
ConnectionData connectionData = new(GetConfiguration(), connectionString: "Server=.; Database=TestDB;Trusted_Connection=True;Application Name=Repository.Test;", Environment.UserName, LogTypeEnum.Application, "SqlServer");
dl.Init(connectionData);
Console.WriteLine(JsonClass.ConvertClassToJson(dl.Query("Select * From Users;")));
}
private static IConfiguration GetConfiguration()
{
string path = "appsettings.json";
if (File.Exists(Path.Combine(AppDomain.CurrentDomain.BaseDirectory, "..\\..\\..\\") + "appsettings.json"))
{
path = Path.Combine(AppDomain.CurrentDomain.BaseDirectory, "..\\..\\..\\") + "appsettings.json";
}
return new ConfigurationBuilder().AddJsonFile(path).Build();
}
}
}
DataLayerContext
Sample Code Init
namespace ConsoleApp.Repository
{
class Program
{
static void Main(string[] args)
{
DataLayerContext<TestDBContext> dl = new();
ConnectionData connectionData = new(GetConfiguration(), connectionString: "Server=.; Database=TestDB;Trusted_Connection=True;Application Name=Repository.Test;", Environment.UserName, LogTypeEnum.Application, "SqlServer");
dl.Init(connectionData);
Console.WriteLine(JsonClass.ConvertClassToJson(dl.ExecuteNonQuery("Insert Into Users (UserId, FirstName, LastName) Values (1, 'Name', 'Surname');")));
}
private static IConfiguration GetConfiguration()
{
string path = "appsettings.json";
if (File.Exists(Path.Combine(AppDomain.CurrentDomain.BaseDirectory, "..\\..\\..\\") + "appsettings.json"))
{
path = Path.Combine(AppDomain.CurrentDomain.BaseDirectory, "..\\..\\..\\") + "appsettings.json";
}
return new ConfigurationBuilder().AddJsonFile(path).Build();
}
}
}
DataLayerModel
The DataLayerGet class is inherited by this class, so all DataLayerGet methods can be used
Sample Code Init
namespace ConsoleApp.Repository
{
class Program
{
static void Main(string[] args)
{
DataLayerModel<TestDBContext, Users> dl = new();
ConnectionData connectionData = new(GetConfiguration(), connectionString: "Server=.; Database=TestDB;Trusted_Connection=True;Application Name=Repository.Test;", Environment.UserName, LogTypeEnum.Application, "SqlServer");
dl.Init(connectionData);
Console.WriteLine(JsonClass.ConvertClassToJson(dl.GetAll()));
}
private static IConfiguration GetConfiguration()
{
string path = "appsettings.json";
if (File.Exists(Path.Combine(AppDomain.CurrentDomain.BaseDirectory, "..\\..\\..\\") + "appsettings.json"))
{
path = Path.Combine(AppDomain.CurrentDomain.BaseDirectory, "..\\..\\..\\") + "appsettings.json";
}
return new ConfigurationBuilder().AddJsonFile(path).Build();
}
}
}
DapperContext
Properties
public ConnectionData? ConnectionData { get; set; }
Methods
void Init(ConnectionData connectionData);
void Init(DbContext context, ConnectionData connectionData);
int Execute(string command, DynamicParameters? parameters = null, IDbTransaction? transaction = null, int? commandTimeoutSecond = null, CommandType? commandType = null, [CallerFilePath] string contextName = "", [CallerMemberName] string eventName = "");
IQueryable<TEntity> Query<TEntity>(string command, DynamicParameters? parameters = null, IDbTransaction? transaction = null, bool buffered = true, int? commandTimeoutSecond = null, CommandType? commandType = null, [CallerFilePath] string contextName = "", [CallerMemberName] string eventName = "");
TEntity? QueryFirstOrDefault<TEntity>(string command, DynamicParameters? parameters = null, IDbTransaction? transaction = null, int? commandTimeoutSecond = null, CommandType? commandType = null, [CallerFilePath] string contextName = "", [CallerMemberName] string eventName = "");
Task<int> ExecuteAsync(string command, DynamicParameters? parameters = null, IDbTransaction? transaction = null, int? commandTimeoutSecond = null, CommandType? commandType = null, [CallerFilePath] string contextName = "", [CallerMemberName] string eventName = "");
Task<IQueryable<TEntity>> QueryAsync<TEntity>(string command, DynamicParameters? parameters = null, IDbTransaction? transaction = null, int? commandTimeoutSecond = null, CommandType? commandType = null, [CallerFilePath] string contextName = "", [CallerMemberName] string eventName = "");
Task<TEntity?> QueryFirstOrDefaultAsync<TEntity>(string command, DynamicParameters? parameters = null, IDbTransaction? transaction = null, int? commandTimeoutSecond = null, CommandType? commandType = null, [CallerFilePath] string contextName = "", [CallerMemberName] string eventName = "");
Sample Code
var dl = new DapperContext<TestDBContext>();
dl.Init(new ConnectionData(configuration, configuration.GetConnectionString("TestDBConnection") ?? "",
Environment.UserName, LogTypeEnum.Application, TypeDBEnum.SqlServer));
dl.Query<Users>("Select * From dbo.Users;");
DataLayerContext
Properties
public ConnectionData? ConnectionData { get; set; }
Methods
void Init(ConnectionData connectionData);
void Init(DbContext context, ConnectionData connectionData);
int Commit([CallerFilePath] string contextName = "", [CallerMemberName] string eventName = "");
int ExecuteNonQuery(string command, List<DbParameter>? parameters = null, [CallerFilePath] string contextName = "", [CallerMemberName] string eventName = "");
T ExecuteScalar<T>(string command, [CallerFilePath] string contextName = "", [CallerMemberName] string eventName = "");
T ExecuteScalar<T>(string command, ref List<DbParameter>? parameters, [CallerFilePath] string contextName = "", [CallerMemberName] string eventName = "");
IQueryable<string> GetDatabaseList([CallerFilePath] string contextName = "", [CallerMemberName] string eventName = "");
IDataLayerModel<TContext, TEntity>? Repository<TEntity>([CallerFilePath] string contextName = "", [CallerMemberName] string eventName = "") where TEntity : ModelBase;
void Rollback([CallerFilePath] string contextName = "", [CallerMemberName] string eventName = "");
Task<int> CommitAsync([CallerFilePath] string contextName = "", [CallerMemberName] string eventName = "");
Task<int> ExecuteNonQueryAsync(string command, List<DbParameter>? parameters = null, [CallerFilePath] string contextName = "", [CallerMemberName] string eventName = "");
Task<T> ExecuteScalarAsync<T>(string command, List<DbParameter>? parameters = null, [CallerFilePath] string contextName = "", [CallerMemberName] string eventName = "");
Task<IQueryable<string>> GetDatabaseListAsync([CallerFilePath] string contextName = "", [CallerMemberName] string eventName = "");
Task RollbackAsync([CallerFilePath] string contextName = "", [CallerMemberName] string eventName = "");
Sample Code
var dl = new DapperContext<TestDBContext>();
dl.Init(new ConnectionData(configuration, configuration.GetConnectionString("TestDBConnection") ?? "",
Environment.UserName, LogTypeEnum.Application, TypeDBEnum.SqlServer));
var entities = dl.GetDatabaseList();
DataLayerContextViewModel : DataLayerContext
Properties
public ConnectionData? ConnectionData { get; set; }
Methods
void Init(DataLayerConfiguration dataLayerConfiguration, [CallerFilePath] string contextName = "", [CallerMemberName] string eventName = "");
void Init(DbContext context, DataLayerConfiguration dataLayerConfiguration, [CallerFilePath] string contextName = "", [CallerMemberName] string eventName = "");
IDataLayerModelViewModel<TContext, TSource, TDestination>? Repository<TSource, TDestination>(MapperConfiguration mapperConfiguration, [CallerFilePath] string contextName = "", [CallerMemberName] string eventName = "")
where TSource : class where TDestination : ModelBase;
Sample Code
var dl = new DapperContextViewModel<TestDBContext>();
dl.Init(new ConnectionData(configuration, configuration.GetConnectionString("TestDBConnection") ?? "",
Environment.UserName, LogTypeEnum.Application, TypeDBEnum.SqlServer));
dl.Repository<UsersViewModel, Users>().GetAll();
DataLayerGet
Properties
public ConnectionData? ConnectionData { get; set; }
Methods
void Init(ConnectionData connectionData);
void Init(DbContext context, ConnectionData connectionData);
bool Any(Expression<Func<TEntity, bool>> predicate);
IQueryable<TEntity> GetAll(string? includeExpressions = null, int? offset = null, int? fetch = null);
IQueryable<TEntity> GetCustom(string? includeExpressions = null, object? query = null);
IQueryable<TEntity> Get(Expression<Func<TEntity, bool>> predicate, string? includeExpressions = null, int? offset = null, int? fetch = null);
IQueryable<TEntity> GetByStoredProcedure(string command);
IQueryable<TEntity> GetByStoredProcedure(string command, ref DbParameter[] parameters);
IQueryable<TEntity> GetDynamic(string where, object[]? parameters = null, string? includeExpressions = null, int? offset = null, int? fetch = null);
TEntity? GetFirstOrDefault(Expression<Func<TEntity, bool>> predicate, string? includeExpressions = null);
Task<bool> AnyAsync(Expression<Func<TEntity, bool>> predicate);
Task<IQueryable<TEntity>> GetAllAsync(string? includeExpressions = null, int? offset = null, int? fetch = null);
Task<IQueryable<TEntity>> GetCustomAsync(string? includeExpressions = null, object? query = null);
Task<IQueryable<TEntity>> GetAsync(Expression<Func<TEntity, bool>> predicate, string? includeExpressions = null, int? offset = null, int? fetch = null);
Task<IQueryable<TEntity>> GetByStoredProcedureAsync(string command);
Task<IQueryable<TEntity>> GetByStoredProcedureAsync(string command, DbParameter[] parameters);
Task<IQueryable<TEntity>> GetDynamicAsync(string where, object[]? parameters = null, string? includeExpressions = null, int? offset = null, int? fetch = null);
Task<TEntity?> GetFirstOrDefaultAsync(Expression<Func<TEntity, bool>> predicate, string? includeExpressions = null);
Sample Code
var dl = new DataLayerGet<TestDBContext, Users>();
dl.Init(new ConnectionData(configuration, configuration.GetConnectionString("TestDBConnection") ?? "",
Environment.UserName, LogTypeEnum.Application, TypeDBEnum.SqlServer));
var entities = dl.GetAll();
DataLayerGetViewModel : DataLayerGet
Properties
public ConnectionData? ConnectionData { get; set; }
public MapperConfiguration AutoMapperConfiguration { get; set; }
Methods
void Init(ConnectionData connectionData);
void Init(DbContext context, ConnectionData connectionData);
bool AnyViewModel(Expression<Func<TSource, bool>> predicate);
IQueryable<TSource> GetAllViewModel(string? includeExpressions = null, int? offset = null, int? fetch = null);
IQueryable<TSource> GetCustomViewModel(string? includeExpressions = null, object? query = null);
IQueryable<TSource> GetViewModel(Expression<Func<TSource, bool>> predicate, string? includeExpressions = null, int? offset = null, int? fetch = null);
IQueryable<TSource> GetByStoredProcedureViewModel(string command);
IQueryable<TSource> GetByStoredProcedureViewModel(string command, ref DbParameter[] parameters);
IQueryable<TSource> GetDynamicViewModel(string where, object[]? parameters = null, string? includeExpressions = null, int? offset = null, int? fetch = null);
TSource? GetFirstOrDefaultViewModel(Expression<Func<TSource, bool>> predicate, string? includeExpressions = null);
Task<bool> AnyViewModelAsync(Expression<Func<TSource, bool>> predicate);
Task<IQueryable<TSource>> GetAllViewModelAsync(string? includeExpressions = null, int? offset = null, int? fetch = null);
Task<IQueryable<TSource>> GetCustomViewModelAsync(string? includeExpressions = null, object? query = null);
Task<IQueryable<TSource>> GetViewModelAsync(Expression<Func<TSource, bool>> predicate, string? includeExpressions = null, int? offset = null, int? fetch = null);
Task<IQueryable<TSource>> GetByStoredProcedureViewModelAsync(string command);
Task<IQueryable<TSource>> GetByStoredProcedureViewModelAsync(string command, DbParameter[] parameters);
Task<IQueryable<TSource>> GetDynamicViewModelAsync(string where, object[]? parameters = null, string? includeExpressions = null, int? offset = null, int? fetch = null);
Task<TSource?> GetFirstOrDefaultViewModelAsync(Expression<Func<TSource, bool>> predicate, string? includeExpressions = null);
Sample Code
var dl = new DataLayerGetViewModel<TestDBContext, UsersViewModel, Users>(ObjectMapper.MapperConfiguration);
dl.Init(new ConnectionData(configuration, configuration.GetConnectionString("TestDBConnection") ?? "",
Environment.UserName, LogTypeEnum.Application, TypeDBEnum.SqlServer));
var entities = dl.GetAllViewModel();
DataLayerModel
Properties
public ConnectionData? ConnectionData { get; set; }
Methods
void Init(ConnectionData connectionData);
void Init(DbContext context, ConnectionData connectionData);
TEntity Add(TEntity entity, Func<TEntity, bool>? predicateDetachLocal = null, [CallerFilePath] string contextName = "", [CallerMemberName] string eventName = "");
IQueryable<TEntity> AddRange(IQueryable<TEntity> entities, Func<TEntity, bool>? predicateDetachLocal = null, [CallerFilePath] string contextName = "", [CallerMemberName] string eventName = "");
void DetachLocal(Func<TEntity, bool> predicateDetachLocal);
void Remove(TEntity entity, Func<TEntity, bool>? predicateDetachLocal = null, [CallerFilePath] string contextName = "", [CallerMemberName] string eventName = "");
void Remove(Expression<Func<TEntity, bool>> predicate, Func<TEntity, bool>? predicateDetachLocal = null, [CallerFilePath] string contextName = "", [CallerMemberName] string eventName = "");
void RemoveRange(IQueryable<TEntity> entities, Func<TEntity, bool>? predicateDetachLocal = null, [CallerFilePath] string contextName = "", [CallerMemberName] string eventName = "");
TEntity Update(TEntity entity, Func<TEntity, bool>? predicateDetachLocal = null, [CallerFilePath] string contextName = "", [CallerMemberName] string eventName = "");
IQueryable<TEntity> UpdateRange(IQueryable<TEntity> entities, Func<TEntity, bool>? predicateDetachLocal = null, [CallerFilePath] string contextName = "", [CallerMemberName] string eventName = "");
bool ValidateEntity(TEntity entity, [CallerFilePath] string contextName = "", [CallerMemberName] string eventName = "");
bool ValidateEntities(IQueryable<TEntity> entities, [CallerFilePath] string contextName = "", [CallerMemberName] string eventName = "");
Task<TEntity> AddAsync(TEntity entity, Func<TEntity, bool>? predicateDetachLocal = null, [CallerFilePath] string contextName = "", [CallerMemberName] string eventName = "");
Task<IQueryable<TEntity>> AddRangeAsync(IQueryable<TEntity> entities, Func<TEntity, bool>? predicateDetachLocal = null, [CallerFilePath] string contextName = "", [CallerMemberName] string eventName = "");
Task RemoveAsync(TEntity entity, Func<TEntity, bool>? predicateDetachLocal = null, [CallerFilePath] string contextName = "", [CallerMemberName] string eventName = "");
Task RemoveAsync(Expression<Func<TEntity, bool>> predicate, Func<TEntity, bool>? predicateDetachLocal = null, [CallerFilePath] string contextName = "", [CallerMemberName] string eventName = "");
Task RemoveRangeAsync(IQueryable<TEntity> entities, Func<TEntity, bool>? predicateDetachLocal = null, [CallerFilePath] string contextName = "", [CallerMemberName] string eventName = "");
Task<TEntity> UpdateAsync(TEntity entity, Func<TEntity, bool>? predicateDetachLocal = null, [CallerFilePath] string contextName = "", [CallerMemberName] string eventName = "");
Task<IQueryable<TEntity>> UpdateRangeAsync(IQueryable<TEntity> entities, Func<TEntity, bool>? predicateDetachLocal = null, [CallerFilePath] string contextName = "", [CallerMemberName] string eventName = "");
Task<bool> ValidateEntityAsync(TEntity entity, [CallerFilePath] string contextName = "", [CallerMemberName] string eventName = "");
Task<bool> ValidateEntitiesAsync(IQueryable<TEntity> entities, [CallerFilePath] string contextName = "", [CallerMemberName] string eventName = "");
Sample Code
var dl = new DataLayerModel<TestDBContext, Users>();
dl.Init(new ConnectionData(configuration, configuration.GetConnectionString("TestDBConnection") ?? "",
Environment.UserName, LogTypeEnum.Application, TypeDBEnum.SqlServer));
var entity = new Users()
{
UserId = 1,
FirstName = "Joao",
LastName = "Manuel"
};
var result = dl.Add(entity);
DataLayerModelViewModel : DataLayerModel
Properties
public ConnectionData? ConnectionData { get; set; }
Methods
void Init(ConnectionData connectionData);
void Init(DbContext context, ConnectionData connectionData);
TSource AddViewModel(TSource entity, Func<TSource, bool>? predicateDetachLocal = null, [CallerFilePath] string contextName = "", [CallerMemberName] string eventName = "");
IQueryable<TSource> AddRangeViewModel(IQueryable<TSource> entities, Func<TSource, bool>? predicateDetachLocal = null, [CallerFilePath] string contextName = "", [CallerMemberName] string eventName = "");
void RemoveViewModel(TSource entity, Func<TSource, bool>? predicateDetachLocal = null, [CallerFilePath] string contextName = "", [CallerMemberName] string eventName = "");
void RemoveViewModel(Expression<Func<TSource, bool>> predicate, Func<TSource, bool>? predicateDetachLocal = null, [CallerFilePath] string contextName = "", [CallerMemberName] string eventName = "");
void RemoveRangeViewModel(IQueryable<TSource> entities, Func<TSource, bool>? predicateDetachLocal = null, [CallerFilePath] string contextName = "", [CallerMemberName] string eventName = "");
TSource UpdateViewModel(TSource entity, Func<TSource, bool>? predicateDetachLocal = null, [CallerFilePath] string contextName = "", [CallerMemberName] string eventName = "");
IQueryable<TSource> UpdateRangeViewModel(IQueryable<TSource> entities, Func<TSource, bool>? predicateDetachLocal = null, [CallerFilePath] string contextName = "", [CallerMemberName] string eventName = "");
bool ValidateEntityViewModel(TDestination entity, [CallerFilePath] string contextName = "", [CallerMemberName] string eventName = "");
bool ValidateEntitiesViewModel(IQueryable<TDestination> entities, [CallerFilePath] string contextName = "", [CallerMemberName] string eventName = "");
Task<TSource> AddViewModelAsync(TSource entity, Func<TSource, bool>? predicateDetachLocal = null, [CallerFilePath] string contextName = "", [CallerMemberName] string eventName = "");
Task<IQueryable<TSource>> AddRangeViewModelAsync(IQueryable<TSource> entities, Func<TSource, bool>? predicateDetachLocal = null, [CallerFilePath] string contextName = "", [CallerMemberName] string eventName = "");
Task RemoveViewModelAsync(TSource entity, Func<TSource, bool>? predicateDetachLocal = null, [CallerFilePath] string contextName = "", [CallerMemberName] string eventName = "");
Task RemoveViewModelAsync(Expression<Func<TSource, bool>> predicate, Func<TSource, bool>? predicateDetachLocal = null, [CallerFilePath] string contextName = "", [CallerMemberName] string eventName = "");
Task RemoveRangeViewModelAsync(IQueryable<TSource> entities, Func<TSource, bool>? predicateDetachLocal = null, [CallerFilePath] string contextName = "", [CallerMemberName] string eventName = "");
Task<TSource> UpdateViewModelAsync(TSource entity, Func<TSource, bool>? predicateDetachLocal = null, [CallerFilePath] string contextName = "", [CallerMemberName] string eventName = "");
Task<IQueryable<TSource>> UpdateRangeViewModelAsync(IQueryable<TSource> entities, Func<TSource, bool>? predicateDetachLocal = null, [CallerFilePath] string contextName = "", [CallerMemberName] string eventName = "");
Task<bool> ValidateEntityViewModelAsync(TDestination entity, [CallerFilePath] string contextName = "", [CallerMemberName] string eventName = "");
Task<bool> ValidateEntitiesViewModelAsync(IQueryable<TDestination> entities, [CallerFilePath] string contextName = "", [CallerMemberName] string eventName = "");
Sample Code
var dl = new DataLayerModelViewModel<TestDBContext, UsersViewModel, Users>();
dl.Init(new ConnectionData(configuration, configuration.GetConnectionString("TestDBConnection") ?? "",
Environment.UserName, LogTypeEnum.Application, TypeDBEnum.SqlServer));
var entity = new UsersViewModel()
{
UserId = 1,
FirstName = "Joao",
LastName = "Manuel"
};
var result = dl.AddViewModel(entity);
MongoDBModel
Properties
public ConnectionData? ConnectionData { get; set; }
Methods
void Init(DataLayerConfiguration dataLayerConfiguration, [CallerFilePath] string contextName = "", [CallerMemberName] string eventName = "");
bool Any(Expression<Func<TDocument, bool>> predicate);
IQueryable<TDocument> GetAll(string? includeExpressions = null, int? offset = null, int? fetch = null);
IQueryable<TDocument> GetCustom(string? includeExpressions = null, object? query = null);
IQueryable<TDocument> Get(Expression<Func<TDocument, bool>> predicate, string? includeExpressions = null, int? offset = null, int? fetch = null);
IQueryable<TDocument> GetDynamic(string where, object?[] parameters = null!, string? includeExpressions = null, int? offset = null, int? fetch = null);
TDocument? GetFirstOrDefault(Expression<Func<TDocument, bool>> predicate, string? includeExpressions = null);
TDocument Add(TDocument entity, [CallerFilePath] string contextName = "", [CallerMemberName] string eventName = "");
IQueryable<TDocument> AddRange(IQueryable<TDocument> entities, [CallerFilePath] string contextName = "", [CallerMemberName] string eventName = "");
void Remove(TDocument entity, [CallerFilePath] string contextName = "", [CallerMemberName] string eventName = "");
void Remove(Expression<Func<TDocument, bool>> predicate, [CallerFilePath] string contextName = "", [CallerMemberName] string eventName = "");
void RemoveRange(IQueryable<TDocument> entities, [CallerFilePath] string contextName = "", [CallerMemberName] string eventName = "");
TDocument Update(TDocument entity, [CallerFilePath] string contextName = "", [CallerMemberName] string eventName = "");
IQueryable<TDocument> UpdateRange(IQueryable<TDocument> entities, [CallerFilePath] string contextName = "", [CallerMemberName] string eventName = "");
bool ValidateEntity(TDocument entity, [CallerFilePath] string contextName = "", [CallerMemberName] string eventName = "");
bool ValidateEntities(IQueryable<TDocument> entities, [CallerFilePath] string contextName = "", [CallerMemberName] string eventName = "");
Task<bool> AnyAsync(Expression<Func<TDocument, bool>> predicate);
Task<IQueryable<TDocument>> GetAllAsync(string? includeExpressions = null, int? offset = null, int? fetch = null);
Task<IQueryable<TDocument>> GetCustomAsync(string? includeExpressions = null, object? query = null);
Task<IQueryable<TDocument>> GetAsync(Expression<Func<TDocument, bool>> predicate, string? includeExpressions = null, int? offset = null, int? fetch = null);
Task<IQueryable<TDocument>> GetDynamicAsync(string where, object?[] parameters = null!, string? includeExpressions = null, int? offset = null, int? fetch = null);
Task<TDocument?> GetFirstOrDefaultAsync(Expression<Func<TDocument, bool>> predicate, string? includeExpressions = null);
Task<TDocument> AddAsync(TDocument entity, [CallerFilePath] string contextName = "", [CallerMemberName] string eventName = "");
Task<IQueryable<TDocument>> AddRangeAsync(IQueryable<TDocument> entities, [CallerFilePath] string contextName = "", [CallerMemberName] string eventName = "");
Task RemoveAsync(TDocument entity, [CallerFilePath] string contextName = "", [CallerMemberName] string eventName = "");
Task RemoveAsync(Expression<Func<TDocument, bool>> predicate, [CallerFilePath] string contextName = "", [CallerMemberName] string eventName = "");
Task RemoveRangeAsync(IQueryable<TDocument> entities, [CallerFilePath] string contextName = "", [CallerMemberName] string eventName = "");
Task<TDocument> UpdateAsync(TDocument entity, [CallerFilePath] string contextName = "", [CallerMemberName] string eventName = "");
Task<IQueryable<TDocument>> UpdateRangeAsync(IQueryable<TDocument> entities, [CallerFilePath] string contextName = "", [CallerMemberName] string eventName = "");
Task<bool> ValidateEntityAsync(TDocument entity, [CallerFilePath] string contextName = "", [CallerMemberName] string eventName = "");
Task<bool> ValidateEntitiesAsync(IQueryable<TDocument> entities, [CallerFilePath] string contextName = "", [CallerMemberName] string eventName = "");
Sample Code
var dl = new MongoDBModel<TestDocument>();
dl.Init(new ConnectionData(configuration, connectionString,
Environment.UserName, LogTypeEnum.Application, TypeDBEnum.MongoDB));
var entities = dl.GetAll();
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. |
Compatible target framework(s)
Included target framework(s) (in package)
Learn more about Target Frameworks and .NET Standard.
-
net8.0
- AspNetCore.IQueryable.Extensions (>= 8.0.0)
- AutoMapper (>= 13.0.1)
- Dapper (>= 2.1.28)
- FluentValidation.AspNetCore (>= 11.3.0)
- Microsoft.EntityFrameworkCore (>= 8.0.2)
- Microsoft.EntityFrameworkCore.InMemory (>= 8.0.2)
- Microsoft.EntityFrameworkCore.Sqlite (>= 8.0.2)
- Microsoft.EntityFrameworkCore.SqlServer (>= 8.0.2)
- MongoDB.Driver (>= 2.23.1)
- Oracle.EntityFrameworkCore (>= 8.21.121)
- Pomelo.EntityFrameworkCore.MySql (>= 8.0.0)
- Solution.Framework.Json (>= 8.0.0)
- Solution.Framework.Logger (>= 8.0.0)
- Solution.Framework.Notifier (>= 8.0.0)
- Solution.Framework.Security (>= 8.0.0)
- System.Linq.Dynamic.Core (>= 1.3.8)
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 |
---|---|---|
8.0.0 | 128 | 2/18/2024 |
7.0.8 | 183 | 11/23/2023 |
7.0.7 | 144 | 11/22/2023 |
7.0.6 | 112 | 11/20/2023 |
7.0.5 | 124 | 11/15/2023 |
7.0.4 | 114 | 11/15/2023 |
7.0.3 | 149 | 11/12/2023 |
7.0.2 | 155 | 9/25/2023 |
7.0.1 | 268 | 2/8/2023 |
7.0.0 | 283 | 1/24/2023 |
6.0.3 | 455 | 8/9/2022 |
6.0.2 | 429 | 8/9/2022 |
6.0.1 | 448 | 8/8/2022 |
6.0.0 | 428 | 8/8/2022 |
5.0.4 | 890 | 12/15/2021 |
5.0.3 | 693 | 10/25/2021 |
5.0.2 | 682 | 10/25/2021 |
5.0.1 | 509 | 10/11/2021 |
5.0.0 | 825 | 10/5/2021 |