Base solution for your next web application
BLACK FRIDAY
From Nov 21
To Dec 1
XXDAYS : XXHRS : XXMIN : XXSEC
SAVE UP TO$3K
Also valid for the
existing customers!
Open Closed

How to use the EF batch function in Repositories? #800


0
wddpct created

When I create an repository like 'Repository', I can't use those methods such as 'AddRange' or others. Here is my code

public class TaskRepository: BrightEyesProjectRepositoryBase<Task,long>, ITaskRepository { public TaskRepository(IDbContextProvider<BrightEyesProjectDbContext> dbContextProvider) : base(dbContextProvider) { }

   public OperationResult InsertTaskList(List&lt;Task&gt; tasks)
   {
       var operationResult = new OperationResult(OperationResultType.Success);

     **var data = Context.Tasks.AddRange(tasks);**// there is a mistake about 'AddRange'.IDbSet&lt;Task&gt; Not included in the definition of 'AddRange'.

       throw new NotImplementedException();
   }
}

Could you fix it, thank you...


3 Answer(s)
  • 0
    hikalkan created
    Support Team

    Because, AddRange is defined in DbSet, not in IDbSet. You've two options:

    1. Just use Table as shown below:

    var data = Table.AddRange(tasks);

    1. Use DbSet instead of IDbSet in your DbContext properties.
  • 0
    wddpct created

    <cite>hikalkan: </cite> Because, AddRange is defined in DbSet, not in IDbSet. You've two options:

    1. Just use Table as shown below:

    var data = Table.AddRange(tasks);

    1. Use DbSet instead of IDbSet in your DbContext properties.

    Thanks a lot!

  • 0
    hikalkan created
    Support Team

    Hi @IvanoFFWiff,

    This question is not related to this topic and ABP framework. You can search web for it, there are many answers.

    Have a nice day.