Platform.EnUnity 1.0.16

The owner has unlisted this package. This could mean that the package is deprecated, has security vulnerabilities or shouldn't be used anymore.
dotnet add package Platform.EnUnity --version 1.0.16
                    
NuGet\Install-Package Platform.EnUnity -Version 1.0.16
                    
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="Platform.EnUnity" Version="1.0.16" />
                    
For projects that support PackageReference, copy this XML node into the project file to reference the package.
<PackageVersion Include="Platform.EnUnity" Version="1.0.16" />
                    
Directory.Packages.props
<PackageReference Include="Platform.EnUnity" />
                    
Project file
For projects that support Central Package Management (CPM), copy this XML node into the solution Directory.Packages.props file to version the package.
paket add Platform.EnUnity --version 1.0.16
                    
#r "nuget: Platform.EnUnity, 1.0.16"
                    
#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.
#:package Platform.EnUnity@1.0.16
                    
#:package directive can be used in C# file-based apps starting in .NET 10 preview 4. Copy this into a .cs file before any lines of code to reference the package.
#addin nuget:?package=Platform.EnUnity&version=1.0.16
                    
Install as a Cake Addin
#tool nuget:?package=Platform.EnUnity&version=1.0.16
                    
Install as a Cake Tool

UnityConfig.cs

    public static void RegisterTypes(IUnityContainer container)
    {
        // factory
        container.RegisterType<IFactory, Factory>().RegisterInstance(container);

        // contexts
        container.RegisterType<IEnUnityDemoContext, EnUnityDemoContext>();
        InjectionConstructor context = new InjectionConstructor(typeof(IEnUnityDemoContext));

        // repositories
        container.RegisterType<IUserRepository, UserRepository>(context)
                 .RegisterType<IRoleRepository, RoleRepository>(context);

    }

EnUnityDemoContext.cs

public class EnUnityDemoContext : UnitOfWork, IEnUnityDemoContext
{
    public EnUnityDemoContext(Transactional transactional) 
        : base(new EnUnityDemoEntities(), transactional)
    {

    }
}

public interface IEnUnityDemoContext : IUnitOfWork
{

}

Repositories

public class RoleRepository : DataRepository<Role>, IRoleRepository
{
    public RoleRepository(IUnitOfWork uow) 
        : base(uow)
    {
    }
}

public interface IRoleRepository : IDataRepository<Role>
{

}

public class UserRepository : DataRepository<User>, IUserRepository
{
    public UserRepository(IUnitOfWork uow) 
        : base(uow)
    {
    }

    public IEnumerable<UserRole> GetUserRoles(string roleName, out int userCount)
    {
        var p = new QParameter(isStoredProc: true);
        p.Parameters = new List<Parameter>
        {
            new Parameter() { Name = "roleName", Value = roleName }
        };

        p.ParametersOut = new List<ParameterOut>
        {
            new ParameterOut() { Name = "userCount", DbType = System.Data.DbType.Int32 }
        };

        var result = base.SqlQuery<UserRole>("sp_GetUserByRole", ref p);

        userCount = p.ParametersOutResult.FirstOrDefault(param => param.Name == "userCount").Value.ToInt();

        return result;
    }
}

public interface IUserRepository : IDataRepository<User>
{
    IEnumerable<UserRole> GetUserRoles(string roleName, out int userCount);
}

HomeController.cs (WITH UnitOfWork)

    private readonly IFactory _factory;
    private IUserRepository _userRepo;
    private IRoleRepository _roleRepo;

    public HomeController(IFactory factory)
    {
        _factory = factory;
    }

    public ActionResult Index()
    {
        using (IUnitOfWork uow = _factory.CreateUnitOfWork<IEnUnityDemoContext>())
        {
            _userRepo = _factory.CreateRepository<IUserRepository>(uow);
            _roleRepo = _factory.CreateRepository<IRoleRepository>(uow);

            var role = _roleRepo.Add(new Models.Role { Rolename = "admin" });

            var user = _userRepo.Add(new Models.User { RoleId = role.Id, Username = "fbasa" });

            uow.SaveChanges();

            return View();
        }
    }

HomeController.cs (WITHOUT UnitOfWork)

    private IUserRepository _userRepo;

    public HomeController(IUserRepository userRepo)
    {
        _userRepo = userRepo;
    }

    public ActionResult Index()
    {
        int userCount;
        var users = _userRepo.GetUserRoles("admin", out userCount);


        return View(new { Users = users, count = userCount });
    }
Product Compatible and additional computed target framework versions.
.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. 
Compatible target framework(s)
Included target framework(s) (in package)
Learn more about Target Frameworks and .NET Standard.

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