2085 1
ASP.NET Core - Dependency Injection

My controller:

    [Route("api/[controller]")]
    [ApiController]
    public class CategoriesController : ControllerBase
    {
        private readonly IUnitOfWork unitOfWork;

        public CategoriesController(IUnitOfWork unitOfWork)
        {
            this.unitOfWork = unitOfWork;
        }

        [HttpGet]
        [Route("TestCategories")]
        public ActionResult<IEnumerable<Category>> TestCategories()
        {
            return unitOfWork.Categories.FindAll().ToList();
        }
    }

My Startup:

        public void ConfigureServices(IServiceCollection services)
        {
            services.Configure<CookiePolicyOptions>(options =>
            {
                // This lambda determines whether user consent for non-essential cookies is needed for a given request.
                options.CheckConsentNeeded = context => true;
                options.MinimumSameSitePolicy = SameSiteMode.None;
            });

            services.AddDbContext<ClassifiedAdsDbContext>(options => options.UseSqlServer(Configuration.GetConnectionString("DefaultConnection")));
            services.AddScoped<IUnitOfWork, UnitOfWork>();
            services.AddMvc().SetCompatibilityVersion(CompatibilityVersion.Version_2_1);
        }

I did break my app so i can understand how the codes work.

As you can see on my controller i used IUnitOfWork (Interface that comes from MyProject.Domain - class library) 

Scenario:

  1. if i use the UnitOfWork class, the only thing the i need to inject (to startup.cs) is the UnitOfWork class only.
  2. if i use the IUnitOfWork interface. i need to inject both (to startup.cs) IUnitOfWork interface and UnitOfWork class as well because it gives error see below.

...

Type
Question
2079 2
Can we test the facebook page manage permission even before the app review premission in granted?

Hi, I would like to know, can we test the page manage permission even before the facebook app review permission are granted,if we edit correctly the users (admins/developers/testers) in the settings of our app. Thanks.

...
Type
Question
2008 1
Fetch multiple table data using Single Query in ASP.NET using Entity framework.

I want to get data from related entity based on multiple conditions in a single query

I have two tables Employee(EmpId,EmpName) and Attendance(AttId,ScanType,ScanTime,EmpId), I want to display data for each month for all Employees. In Attendance table Scan type have multiple values for in-time and out-time. I want to select smallest value as in-time and largest value as out-time for each employee and store for each employee in view model. ViewModel(EmpId,In-time,Outtime).

What will be the query for this?

 

...
Type
Question
1969 2
Login with Facebook using Oauth redirect us to full page, how can replace it with pop-up in ASP.NET?

Hi, I'm using Oauth to login with facebook account as shown in the below image

When have clicking on the facebook button

...

Type
Question
1953 0
Error System.NullReferenceException while accessing Parent entity property in child entity

I am trying to access a property of parent entity which is on one side of relation while in child entity but it is giving me null reference exception. May be its problem of lazy loading which is not available in entity framework core 2.0. How to access it in core 2.0. These are details of problem

...
Type
Question

1936 0
Run or Execute Stored Procedure using EF Core
In this article, I have mentioned how we can run or execute Stored procedure in ASP.NET Core 6+ using Entity Framework Core.
Type
Article
1904 1
working with PAGES APIS under developement mode to manage page facebook

Hi, my app is still not aproved by facebook. I heve tried following this link https://qawithexperts.com/questions/351/error-requires-either-publishtogroups-permission-and-app-bei but still now, I haven't heard from facebook yet. I think to deal with apis pages under developement mode.

1 - I have created a new app under my account facebook , and keep the developement mode.

2 - I have get the page access token.

...

Type
Question
1806 0
HTML to PDF in ASP.NET Core
In this article, I have mentioned how we can convert HTML razor view to PDF in ASP.NET Core using jsreport NuGet package.
Type
Article
1750 2
How to Login using facebook page(Admin users) instead of facebook Email using OAuth in MVC?

Hi. I need to create a login page where the user is requested to register using his Facebook page, instead of facebook Id, where he is the admin of the facebook page.

I'm using Oauth to login with facebook but want that user to register using his Facebook page for which user is the community manager(admin) while giving permissions to access page's fans information.

...
Type
Question
1687 0
Re-request facebook details, if User denies scope ("manage_page") using Startup.cs in ASP.NET Core

Hi, 

Facebook docs give this javascript code as shown below for oAuth login re-request

...
Type
Question

Page 30 of 31