Code Monkey home page Code Monkey logo

dataaccess_aspnetcore_deprecated's Introduction

DataAccess Toolbox

The DataAccess Toolbox contains the base classes for data access in ASP.NET Core with Entity Framework Core 1.0 using the unit-of-work and repository pattern.

It contains :

  • base classes for entities.
  • base classes for repositories.
  • generic repositories.
  • unit-of-work and repository pattern. (- automatic discovery of repositories -- not yet)

Table of Contents

Installation

Adding the DataAccess Toolbox to a project is as easy as adding it to the csproj project file:

  <ItemGroup>
    <PackageReference Include="Digipolis.DataAccess" Version="4.0.0" />
  </ItemGroup>

or if your project still works with project.json :

 "dependencies": {
    "Digipolis.DataAccess":  "4.0.0"
 }

For netcoreapp2.0-projects a package version >= 4.0.0 must be used. For netcoreapp1.x-projects use a package version < 4.0.0. A separate branch (netstandard_1_6) has been created to apply changes for the older version if necessary.

Make sure you have our Nuget feed configured (https://www.myget.org/F/digipolisantwerp/api/v3/index.json.).

Alternatively, it can also be added via the NuGet Package Manager interface.

Configuration in Startup.ConfigureServices

The DataAccess framework is registered in the ConfigureServices method of the Startup class.

services.AddDataAccess<MyEntityContext>();

Next to this registration you will need to register entity framework separately.

NpgSql

If you use NpgSql, you can for example use this entity framework configuration:

var connection = @"Server=127.0.0.1;Port=5432;Database=TestDB;User Id=postgres;Password=mypwd;";
services.AddDbContext<MyEntityContext>(options => options.UseNpgsql(connection));

Check the Entity Framework documentation for more info on the configuration possibilities.

EntityContext

You inherit a DbContext object from the EntityContextBase class in the toolbox. This context contains all your project-specific DbSets and custom logic. The constructor has to accept an DbContextOptions<TContext> as input parameter, to be passed to the base constructor and where TContext is the type of your context. The EntityContextBase is a generic type with your context as type parameter. This is necessary in order to pass the generic DbContextOptions object to the underlying DbContext constructor.

For example :

public class EntityContext : EntityContextBase<EntityContext>
{
    public EntityContext(DbContextOptions<EntityContext> options) : base(options)
    { }

    public DbSet<MyEntity>
    MyEntities { get; set; }
    public DbSet<MyOtherEntity>
    MyOtherEntities { get; set; }

    protected override void OnModelCreating(DbModelBuilder modelBuilder)
    {
        // optional, see Entity Framework documentation
    }
}

ModelBuilder extensions

Sometimes you want more control over the way the database structure is layed out (e.g. you are bound by rules set by the database administrators), other times you might already have a database in place and you can't change the structure. The EF ModelBuilder allows you to control the mapping of the CLR types to the database schema. The following extensions give you extra possibilities that are not included in the standard Entity Framework libraries.

Set all table- and field-names to lowercase

protected override void OnModelCreating(ModelBuilder modelBuilder)
{
    base.OnModelCreating(modelBuilder);

    modelBuilder.LowerCaseTablesAndFields();
}

Disable cascading deletes

protected override void OnModelCreating(ModelBuilder modelBuilder)
{
    base.OnModelCreating(modelBuilder);

    modelBuilder.DisableCascadingDeletes();
}

Entities

Your Entities are inherited from the base class EntityBase in the toolbox :

public class MyEntity : EntityBase
{
    public string MyProperty { get; set; }
}

The EntityBase class already contains an int property, named Id that can be used as primary key.

UnitOfWork

The toolbox contains a UnitOfWork class and IUnitofWork interface that encapsulates the DbContext and that you use in your business classes to separate the data access code from business code. The IUnitOfWork is instantiated by the IUowProvider.

First inject the IUowProvider in your business class :

public class BusinessClass
{
    public BusinessClass(IUowProvider uowProvider)
    {
        _uowProvider = uowProvider;
    }

    private readonly IUowProvider _uowProvider;
}

Then ask the IUowProvider for a IUnitOfWork :

using ( var uow = _uowProvider.CreateUnitOfWork() )
{
    // your business logic that needs dataaccess comes here
}

You can pass in false if you don't want the change tracking to activate (better performance when you only want to retrieve data and not insert/update/delete).

Now access your data via repositories :

var repository = uow.GetRepository<MyEntity>();
// your data access code via the repository comes here

The UnitOfWork will be automatically injected in the repository and used to interact with the database.

To persist your changes to the database, call the SaveChanges or SaveChangesAsync method of the IUnitOfWork :

uow.SaveChanges();

Repositories

The toolbox registers generic repositories in the ASP.NET Core DI container. They provide the following methods :

Get and GetAsync

Retrieve a single record by id, optionally passing in an IncludeList of child entities that you also want retrieved :

using (var uow = _uowProvider.CreateUnitOfWork())
{
    var repository = uow.GetRepository<MyEntity>();

    // retrieve MyEntity with id = 5
    var entity = repository.Get(5);

    // retrieve MyEntity with id 12 and its child object
    var includeList = new IncludeList<MyEntity>(e => e.Child);
    var entity2 = repository.Get(12, includes: includeList);
}

GetAll and GetAllAsync

Retrieves all records, with or without child records.

using (var uow = _uowProvider.CreateUnitOfWork(false))
{
    var repository = uow.GetRepository<MyEntity>();
    var entities = repository.GetAll(includes: includes);
}

Any and AnyAsync

Checks if at least one record exists with the provided filter.

using (var uow = _uowProvider.CreateUnitOfWork(false))
{
    var repository = uow.GetRepository<MyEntity>();
    bool exists = repository.Any(filter: filter);
}

Add

Adds a record to the repository. The record is persisted to the database when calling IUnitOfWork.SaveChanges().

using (var uow = _uowProvider.CreateUnitOfWork())
{
    var repository = uow.GetRepository<MyEntity>();
    repository.Add(newEntity);
    uow.SaveChanges();
}

Update

Updates an existing record.

Important note! When you update an entity with children objects, these child objects will also be updated. There is no need to update al the child objects separately. This is a new behaviour from the entity framework core update method on the DbSet.

using (var uow = _uowProvider.CreateUnitOfWork())
{
    var repository = uow.GetRepository<MyEntity>();
    repository.Update(updatedEntity);
    await uow.SaveChangesAsync();
}

Remove

You can call this method with an existing entity :

using (var uow = _uowProvider.CreateUnitOfWork())
{
    var repository = uow.GetRepository<MyEntity>();
    repository.Remove(existingEntity);
    await uow.SaveChangesAsync();
}

Or with the Id of an existing entity :

using (var uow = _uowProvider.CreateUnitOfWork())
{
    var repository = uow.GetRepository<MyEntity>();
    repository.Remove(id);
    uow.SaveChangesAsync();
}

Custom Repositories

When you need more functionality in a repository than the generic methods, you can create our own repositories by inheriting from the repository base classes.

To make a repository that is tied to 1 entity type, you inherit from the EntityRepositoryBase class :

public class MyRepository<MyEntity> : EntityRepositoryBase<MyDbContext, MyEntity> , IMyRepository
{
    public MyRepository(ILogger logger) : base(logger, null)
    { }
}

This base class already contains the generic Add, Update, Delete, Get and Query methods.

If you just want to start with an empty repository or a repository that is not tied to 1 type of entity, inherit from the RepositoryBase class :

public class MyRepository : RepositoryBase, IMyRepository
{
    public MyRepository(ILogger logger) : base(logger, null)
    { }
}

Don't forget to register your own repositories in the DI container at startup :

services.AddTransient<IMyRepository, MyRepository>();        // or any other scope (Scoped, Singleton).

Query

These helpers help generating queries:

Filter

A Filter holds the requested filter (WHERE) values.

List<`Participant`> participants = null;

using (var uow = _uowProvider.CreateUnitOfWork(false))
{
    Filter<Entities.Participant>
    filter = new Filter<Entities.Participant>
    (null);

    filter.AddExpression(e => idList.Contains(e.Id));

    var repository = uow.GetRepository<IRepository<Participant>>();

    participants = (await repository.QueryAsync(filter.Expression, includes:includes)).ToList();
}

Includes

Holds the parameters to generate the Include part of the query.

var includes = new Includes<Building>(query =>
{
    return query.Include(b => b.Appartments)
                    .ThenInclude(a => a.Rooms);
}); 

buildings = await repository.GetAllAsync(null, includes.Expression);

OrderBy

Holds the parameters to generate the OrderBy part of the query.

var orderBy = new OrderBy<Entities.Participant>(string.IsNullOrEmpty(paging.Sort) ? "Reservation.DateOfReservation" : paging.Sort, paging.Descending);

Paging

When working with large collections of data you'll want to keep your application performant. Instead of retrieving all records, you can serve your data to the consumer in pages.

The repositories have methods that can be used with paging systems. You can also inject a IDataPager object in your classes to retrieve paged data :

public class MyBusinessClass
{
    public MyBusinessClass(IDataPager<MyEntity> pager)
    {
        _pager = pager;
    }

    private readonly IDataPager<MyEntity> _pager;
}

and call its methods to retrieve paged data :

var pageNumber = 1;
var pageLength = 10;

var data = _pager.Get(pageNumber, pageLength);

var filter = new Filter<MyEntity>(e => e.AProperty == true);

var filteredData = _pager.Query(pageNumber, pageLenght, filter);

dataaccess_aspnetcore_deprecated's People

Contributors

belgian-coder avatar dgpaspnet avatar erikseynaeve avatar jeroendesmetdigipolis avatar jimmyhannon avatar kstr avatar lanoli avatar robliekens avatar stevenvandenbroeck avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

dataaccess_aspnetcore_deprecated's Issues

Reason of IUnitOfWork and UnitOfWork

Hi;
What's the reason for creating IUnitOfWork and UnitOfWork in Uow Layer?
Is it for customization? For example add custome function in UnitOfWork?
Why methods like SaveChanges and SaveChangesAsync signature exist in both IUnitOfWork and IUnitOfWorkBase?

thanks in advance

Inherited Entity

myFurnitureBase :BaseEntity {
  string Name;
  string Description;
}


myHomeFurnitureEntity : myFurnitureBase {
  string myTalbeSpecificProperty;
}


myOfficeFurnitureEntity : myFurnitureBase {
  string myChairSpecificProperty;
}

... there is more type

  dbset<myHomeFurnitureEntity>
  dbset<myOfficeFurnitureEntity >
... 

and
Is that possible to query myHomeFurnitureEntity and myOfficeFurnitureEntity as myFurnitureBase
or how to create generic repository/pager dynamically

I want to show a page that wil list with category,

          if query string/model 
                contains home then 
                    controller must return from myHomeFurnitureEntity as myFurnitureBase 
               contains work then 
                    controller must return from myOfficeFurnitureEntity as myFurnitureBase 

thanks.

Include inner join

Hi,
I wanna take inner join in query when im using include?
How to make this?

Another way to write

Hello,

Is there an another solution than the classic on to right with your framework?
return customerRepo.GetAll().Where(x => x.Reference.ToLower() == reference.ToLower()).FirstOrDefault();

Thanks,

Prefix of ID

hi, our tables has prefix like m_Id or doc_Id, but in this implementation it seems that (EntityBase) force us to use (Id).

Update to Core 2.0

Do you currently have any plans to upgrade this project, as well as the web_aspnetcore, to the new 2.0 release of dotnet core?

Primary key data type other than integer

Hi,
I liked this library very much. Thanks for good work. I have question though. Currently EntityBase class in library is defined as follows.
public class EntityBase
{
[Key]
public int Id { get; set; }
}

What if I need to use different Key i.e. GUID as key or instead of "Id" name use different Key e.g. "UserId".
Is there any way I can override data type and name of Key property here? If not name then at least data type?
Regards
Pankaj

EntityBase location

Hello,

Why when I place the class EntityBase in another project (with the same namespace) I get a crash. Of course my models (my entities) are not in the WebApi project but in a separate project.

Then I'd like a project just with the EntityBase to inherit from in my entities and a the framework with a dependency on the EntityBase project. But I get a crash.

Any idea why ?

Register two database context

Hi,

Do you have a sample on using two database context in a single app? In my app i did like below.

services.AddDbContext<DbContext1>();
services.AddDataAccess<DbContext1>();

services.AddDbContext<DbContext2>();
services.AddDataAccess<DbContext2>();

DbContext1 and DbContext2 are configured to connect to a different SQL DB but i noticed the queries seems to always go to DbContext1.

Appreciate your inputs and advice to help me put in the right track.
Thanks.

Update/Delete/Insert in a bulk

Hi,

This is an great job, its clear and easy to custom.
I can insert/update/delete for single item now. Can i do it with multi items?

Some things like:
Item.Save(); // for single item
ItemList.Save(); // for multi items

Thanks,
Thanh.

One to many update

I am having POCO classes as follows.

`public partial class Account : EntityBase
{
    public Account()
    {
        this.Discounts = new List<Discount>();          
    }

    public string AccountNo { get; set; }
    public string Name { get; set; }
    public IList<Discount> Discounts { get; set; }
}`

`public partial class Wholesaler : EntityBase
{
    public Wholesaler()
    {          
        this.Discounts = new List<Discount>();           
    }

    public string Name { get; set; }     
    public bool HasDiscount { get; set; }
    public IList<Discount> Discounts { get; set; }
}

`public partial class Discount 
{
    public int WholesalerRef { get; set; }
    public int AccountRef { get; set; }
    public decimal DiscountValue { get; set; }     
    public virtual Wholesaler Wholesaler { get; set; }       
    public virtual Account Account { get; set; }
}`

I have created the Discount class with the key of AccountRef & WholesalerRef . Is it OK to create a class without inheriting "EntityBase"?

       `entity.HasKey(e => new { e.AccountRef, e.WholesalerRef });
     
        entity.HasOne(e => e.Account)
            .WithMany(e => e.Discounts)
            .HasForeignKey(e => e.AccountRef)
            .HasConstraintName("FK_Discount_Account");

        entity.HasOne(e => e.Wholesaler)
            .WithMany(e => e.Discounts)
            .HasForeignKey(e => e.WholesalerRef)
            .HasConstraintName("FK_Discount_Wholesaler");`

When I insert a record it is working fine but when update I am getting an error.

System.InvalidOperationException occurred
HResult=0x80131509
Message=The instance of entity type 'Discount' cannot be tracked because another instance of this type with the same key is already being tracked. When adding new entities, for most key types a unique temporary key value will be created if no key is set (i.e. if the key property is assigned the default value for its type). If you are explicitly setting key values for new entities, ensure they do not collide with existing entities or temporary values generated for other new entities. When attaching existing entities, ensure that only one entity instance with a given key value is attached to the context.
Source=
StackTrace:
at Microsoft.EntityFrameworkCore.ChangeTracking.Internal.IdentityMap1.Add(TKey key, InternalEntityEntry entry) at Microsoft.EntityFrameworkCore.ChangeTracking.Internal.StateManager.StartTracking(InternalEntityEntry entry) at Microsoft.EntityFrameworkCore.ChangeTracking.Internal.InternalEntityEntry.SetEntityState(EntityState oldState, EntityState newState, Boolean acceptChanges) at Microsoft.EntityFrameworkCore.ChangeTracking.Internal.EntityGraphAttacher.PaintAction(EntityEntryGraphNode node) at Microsoft.EntityFrameworkCore.ChangeTracking.Internal.EntityEntryGraphIterator.TraverseGraph(EntityEntryGraphNode node, Func2 handleNode)
at Microsoft.EntityFrameworkCore.ChangeTracking.Internal.NavigationFixer.NavigationCollectionChanged(InternalEntityEntry entry, INavigation navigation, IEnumerable1 added, IEnumerable1 removed)
at Microsoft.EntityFrameworkCore.ChangeTracking.Internal.InternalEntityEntryNotifier.NavigationCollectionChanged(InternalEntityEntry entry, INavigation navigation, IEnumerable1 added, IEnumerable1 removed)
at Microsoft.EntityFrameworkCore.ChangeTracking.Internal.ChangeDetector.DetectNavigationChange(InternalEntityEntry entry, INavigation navigation)
at Microsoft.EntityFrameworkCore.ChangeTracking.Internal.ChangeDetector.DetectChanges(InternalEntityEntry entry)
at Microsoft.EntityFrameworkCore.ChangeTracking.Internal.ChangeDetector.DetectChanges(IStateManager stateManager)
at Microsoft.EntityFrameworkCore.DbContext.SaveChanges(Boolean acceptAllChangesOnSuccess)
at DataAccess.Uow.UnitOfWorkBase`1.SaveChanges() in

I am updating as below.

 `var accountDb = _repository.Get(account.Id, query => query.Include(b => b.Discounts));           
  destination.Discounts.Clear();
  accountDb .Name = source.Name;
  accountDb .AccountNo = source.AccountNo;
  destination.Discounts. = source.Discounts;  
 
_repository.Update(accountDb);
_unitOfWork.SaveChanges();`

Could you please let me know there is any workaround to tackle this issue using your repository pattern?

Regards,
Saath

Recursive/Hierarchical query

Is there any way to select an item id and all its children ids with one query?

I have entity:

public class Comment
{
   public int Id {get;set;}
   public int ParentId {get;set;}
   public int Text {get;set;}
}

I have an ID, so I want to select Comment with ID and all its children with subchildren. Example:

1
-2
--3
-4
-5
--6
2
3

If ID == 1 then I want a list of 1,2,3,4,5,6.

I want to avoid using mulitple gets to achieve this result.

Grtz and thanks in advance,

Philippe Devel

[email protected]

Package not found on nuget

I tried adding Digipolis.DataAccess package from nuget repository however couldn't find it there.
Also searched on nugget.org. Is it available via nugget repository or do I need to use source code?
Regards

Example

Can you give me an example?

Thank you.

Using identity

Hello,

I added this :
public class EntityBaseWithIdentityUser : IdentityUser { [Key] public int Id { get; set; } }

I derived one of my entity from this class, the others from the original class EntityBase

In the startup.cs
services.AddDataAccess<MyContext>() .AddIdentity<Customer, IdentityRole>();

and added app.UseIdentity();

In the constructor of ValueController I have this :
public ValueController ( MyContext context, SignInManager<Customer> signInMgr, UserManager<Customer> userMgr, IPasswordHasher<Customer> hasher, ILogger<AuthController> logger, IConfigurationRoot config) {}
But I get an an error 500, did you try this feature ? Is it possible this problem is your framework related ?

Thanks,

GetProperty problem in core 1.0.1

hi
i get error in

(OrderBy.cs) : after updating sample app core packages

PropertyInfo propertyInfo = entityType.GetProperty(propertyName, BindingFlags.IgnoreCase | BindingFlags.Public | BindingFlags.Instance);

Error:
'Type' does not contain a definition for 'GetProperty' and no extension method 'GetProperty' accepting a...

Automatically register repositories in the DI container at startup

All classes inheriting from the repository base classes could be automatically registered in the DI container. This removes the need for the developer to do this when he/she makes custom repositories.
Via the options the developer can be given the choice teo enable/disable this and give the scope of the registration (Transient, Scoped, Singleton).

Example for custom repository

Can you please add an example for the custom repository?

Must it also be generic or can it be focused on a specific class/type?

Thank you!

Login Fails after Changing password success

I have an issue: I have used Identity, i have updated password success, but i can not login until i restart the application.

I think there is an issue with the DbContext DI, this is my code:

in Startup.cs

services.AddDbContext<TCMSContext>(options => options.UseSqlServer(_config["ConnectionStrings:TCMSContextConnection"]));
            services.AddDataAccess<TCMSContext>();

In Controller:

public async Task<IdentityResult> UpdateUser(UserUpdateModel userModel) 
        {
            var user = await _userManager.FindByNameAsync(userModel.UserName);

            var result = await _userManager.ChangePasswordAsync(user, userModel.CurrentPassword, userModel.Password);

            if (result.Succeeded)
            {
                user = await _userManager.FindByNameAsync(userModel.UserName);
                user.Address = userModel.Address;
                user.Avatar = userModel.Avatar;
                user.FullName = userModel.FullName;
                user.Email = userModel.Email;
                user.PhoneNumber = userModel.PhoneNumber;
                result = await _userManager.UpdateAsync(user);
            }

            return result;
        }

Do you have any suggest?
Thank you.

Include with filter

Is that possible to add filter to included entities.. I want only subcategories that active is true

      Func<IQueryable<Category>, IQueryable<Category>> func = 
             query => {
                return query.Include(b => b.SubCategories)
                            .ThenInclude(a => a.SubCategories);
             };
      await repository.QueryAsync(
              t => 
                    t.ParentId == parentId && t.active == true && t.skipmenu == false, 
                    null,
                    func
      );

error CS1061 DbContextOptionsBuilder

Hello,

When I use SQL Server, the compilation ok but at runtime I get this error
error CS1061 DbContextOptionsBuilder does not contain a definition for 'UseSQLServer' and no extension method 'UseSQLServer'

public void ConfigureServices(IServiceCollection services)
{
services.AddDbContext(options => options.UseSqlServer(".......")); //(A)
services.AddDataAccess();
services.AddMvc();
}

The error occur on line (A) .

The reference about EntitiyFramework are 1.1.2 and the using are
using Microsoft.AspNetCore.Builder;
using Microsoft.AspNetCore.Hosting;
using Microsoft.Extensions.Configuration;
using Microsoft.Extensions.DependencyInjection;
using Microsoft.Extensions.Logging;
using Microsoft.EntityFrameworkCore;

I really don't understand :(

Thanks,

Can not register DbContext in startup.cs

I have this DbContext:
public class WorldContext : EntityContextBase<IdentityDbContext<WorldUser>> { }
then in startup.cs, i add the following in ConfigureServices:
services.AddDataAccess<WorldContext>();

Then i met the error:
The type 'TheWorld.Models.WorldContext' cannot be used as type parameter 'TEntityContext' in the generic type or method 'ServiceCollectionExtentions.AddDataAccess<TEntityContext>(IServiceCollection)'. There is no implicit reference conversion from 'TheWorld.Models.WorldContext' to 'Digipolis.DataAccess.Context.EntityContextBase<TheWorld.Models.WorldContext>'.

How to work fine with IdentityDbContext

how to compatible asp.net identity:

my code is here:
public class MyContext : IdentityDbContext<User, Role, long>
public partial class User : IdentityUser

can EntityBase and EntityContextBase change to interface?

Stored Procedure

Hİ,
This architecture is very good,
İ have a question , when i want to use stores procedure in query ('for full text search ')
how to inject ?

could you take example pls ?

IEntityContext access level

Is there a reason why the IEntityContext access level is set tot internal? To customize any class that uses IEntityContext, would take changing all the classes that use IEntityContext.

Using several connectionstring

Hello,

First, I'd like to thank you for your great job.

In an Web application consuming a webApi, this WebApi use (should) your DAL. When a user try the consume it, they need to login first. I give a sample : companyA\user1 or companyB\user25 the connectionstring name are : companyA or companyB . Depending of this value, the context use a database or another, same schema but another database. Each company has is own database. Is there an easy way to give the connectionstring name for each request ?

Thanks,

ViewModel or Dto, How to

I think i need help about Tnetity Mapping,
I dont want to return all fields to client as described in model

Is there any solution for mapping ?

Join 2 or more tables

How can i join 2 or more 2 tables (these table haven't relationship)?

Thank you. :)

Order by Function usage

Hi,

` List urlRecords = null;

        using (var uow = _uowProvider.CreateUnitOfWork(false))
        {
            Filter<UrlRecord>
            filter = new Filter<UrlRecord>(null);

            filter.AddExpression(e => e.EntityId == entityId 
                                    && e.EntityName == entityName
                                    && e.LanguageId == languageId);

            var repository = uow.GetRepository<UrlRecord>();
            **var orderBy = new OrderBy<UrlRecord>(string.IsNullOrEmpty(paging.Sort) ? "Reservation.DateOfReservation" : paging.Sort, paging.Descending);**
            urlRecords = (repository.Query(filter.Expression, orderBy, null)).ToList();
        }`

i am not sure about orderby arguments, can you give me an example for this?

Thank you.

Create instance of IUowProvider in Singleton class

How can i create an instance of IUowProvider?

I have a singleton class like this and need to create instance:

`
public class SystemConfig : ISystemConfig

  {
    private static SystemConfig SystemConfigInstance = new SystemConfig(default(UowProvider));// problem here

   public SystemConfig(IUowProvider uowProvider)
    {
        _uowProvider = uowProvider;
   `}

    public static SystemConfig GetInstace()
    {
        if (SystemConfigInstance == null)
        {
            lock (typeof(SystemConfig))
            {
                if (SystemConfigInstance == null)
                {
                    SystemConfigInstance = new SystemConfig(default(UowProvider));
                }

            }
        }
        return SystemConfigInstance;
    }
 }

Unit Of work Begintransaction

I am working to add new feature to UOW, but your framework is a bit complicated.
Where should I add Begintransaction and Commit And Rollback.
Thank you for responding..

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.