Get List of Data from a table in DB from the Plugin I created in NopCommerce 4.2

This topic was automatically closed 365 days after the last reply. New replies are no longer allowed.
3 years ago
Hey I have developed a plugin with Database operation functionality and it is working fine.
I'm able to perform Insertion & updation operations, but there is no interface available to get list of data from that table.

There is a generic method to generate DBSet, and that only provides interface for finding any entry.


var fooDetails = _db.Set<FooDetails>();
var data = fooDetails.FindAsync(......);


but, is there any interface like,

var fooDetails = _db.Set<FooDetails>();
var data = prescriptionDetails.ToListAsync();


Or do I need to add my own DBSet entry into the following code:-


public partial class FooObjectContext : DbContext, IDbContext
{
      public new virtual DbSet<TEntity> Set<TEntity>() where TEntity : BaseEntity
      {
          return base.Set<TEntity>();
      }

    // Should I Add following line ???
     public DbSet<FooDetails> FooDetails { get; set; }    
}


If, required, I can add all relevant code.
3 years ago
[Update]

I tried doing so, but it provides same interface as:-

var prescriptionDetails = _db.Set<PrescriptionDetails>();
var data= await prescriptionDetails.FindAsync(.......);


Can you tell me how to list the table data?
3 years ago
Hi,

Please refer below documentation...it will guide you how to get data from table (created by plugin).

https://docs.nopcommerce.com/en/developer/plugins/plugin-with-data-access.html

Thank you.
3 years ago
I have went through that, and was able to create the plugin, do insertion & updation & deletion of values, but I have no clue how I can get list of saved values.
I am pretty new to NopCommerce, and I wan't able to find a solution for that any where. can someone please help me out.
3 years ago
Thanks for helping me out!.
Now the issue has been resolved. I have found multiple methods to achieve this.

In my case, I was missing the using statement, :P
 Using System.Linq;


The following post was helpful & is related to the same issue.
https://www.nopcommerce.com/en/boards/topic/44356/get-a-list-from-database
This topic was automatically closed 365 days after the last reply. New replies are no longer allowed.