Skip to content

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

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
bodyquest opened this issue Feb 8, 2020 · 0 comments

Comments

@bodyquest
Copy link

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

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant