Skip to content

Custom AutoMapping in ASP.NET Core as per lecture "Advanced Topics I" gives me unusual error #55

@bodyquest

Description

@bodyquest

Hi Niki,

Despite doing exactly as in the lecture about the AudiCars and the custom mapped property "YearAndMonth", I get a rare error which I can't even solve from SOF or Google.

It is :
InvalidOperationException: Null TypeMapping in Sql Tree
I tried also to remove the sorting from the LINQ Query in case something with my dates is not ok, but problem remains

Here is where it happens.
The BOLD lines of code are marked where error happens. I attached a full copy of the stack to this issue

`RPM.Services.Data.Cars.CarService.GetTopCars(int count) in CarService.cs

        {
            this.context = context;
        }
        public IEnumerable<TViewModel> GetTopCars<TViewModel>(int count = 2)
        {
            **var cars = this.context.Cars**
                .OrderByDescending(x => x.CreatedOn)
                .Take(count)
                .To<TViewModel>()
                .ToList();
            return cars;

RPM.Web.Controllers.HomeController.Index() in HomeController.cs

        {
            this.carsService = carsService;
        }
        public IActionResult Index()
        {
            **var cars = this.carsService.GetTopCars<HomePageCarViewModel>(2);**

            return this.View(cars);
        }
        public IActionResult Privacy()
        {
            return this.View();

`
You successfully demonstrated how it happens. I just need a clue what could cause this on my side..
I also created manually 2 Cars and several CarModels from MSSMS and this is how I was replicating what you demonstrated. But with no success.
Side note: It works on my side as per your demonstration with the automapping up until the custom mapping example.

Null_TypeMapping.txt

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions