Untitled

 avatar
unknown
plain_text
a year ago
1.3 kB
4
Indexable
test case 


[Test]
        public async Task ProductsTest(){
            var options = new DbContextOptionsBuilder<TemplateContext>()
                 .UseMySql(ConnectionStrings, new MySqlServerVersion(new Version(8, 0, 23)))
                 .Options;
            using (var dbContext = new TemplateContext(options))
            {
                var repo = new Repo(dbContext);
                var result = await repo.Products();
                List<Inventory> Products = (List<Inventory>)result;
                Console.WriteLine(result);
                
            }
        }



repo method 

    public async Task<Object> Products()
    {

        try
        {
                var inventory =await(from i in _context.Inventories 
                                     from c in _context.Categorynames 
                                     where i.CategoryId==c.CategoryId && i.IsDelete==true
                                     select new {i.ProductId,i.ProductName,i.Price,i.Quantity,c.Category,i.ProductImage} ).ToListAsync();
                                        
                return  inventory;
        }
            
        catch (Exception ex)
        {
              throw new Exception("No product Found ",ex);
        }
    }
Editor is loading...
Leave a Comment