Giter VIP home page Giter VIP logo

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

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...

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.

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;
    }
 }

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.

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

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,

Join 2 or more tables

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

Thank you. :)

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..

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

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!

Example

Can you give me an example?

Thank you.

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

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,

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).

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,

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).

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>'.

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.

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 ?

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 ?

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

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.

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?

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?

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.

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]

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,

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
      );

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 ?

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.

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.