Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8570961
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 11, 20262026-06-11T18:40:41+00:00 2026-06-11T18:40:41+00:00

What I’m trying to do is to get particular values from my DB and

  • 0

What I’m trying to do is to get particular values from my DB and parse that into view to display it in the table.
I had same problem as in The model item passed into the dictionary is of type …. {Models.App} but what I passed is {Models.App, System.Double} and tried to solve my problem in the similar way. So basically I created a class in the model that has:

 public Vehicle manur_name {get; set;}
 public Vehicle manur_date { get; set; }
 public Vehicle daily_hire_rate { get; set; }

but then when I use it in my controller in the linq query it gives me and error.

 var s = from veh in db.Vehicles
 join c in db.VehicleCategories on veh.vehicle_category_code equals  c.
 join m in db.Models on veh.model_code equals m.model_code
 join man in db.Manufacturers on veh.manufacturer_code equals man.manufacturer_code
 where c.vehicle_category_description == cat && m.body_style == b                         
            select new CarClass {
                          manur_name = man.manufacturer_name, 
                          manur_date = m.model_code, 
                          daily_hire_rate = veh.daily_hire_rate};

It gives me the error:

error:Cannot implicitly convert type ‘decimal’ to
‘carRentalMVC.Models.Vehicle’ Cannot implicitly convert type ‘string’
to ‘carRentalMVC.Models.Vehicle’ Cannot implicitly convert type
‘string’ to ‘carRentalMVC.Models.Vehicle’

Here is what I have in controller after fixing the problem:

        CarRentalDatabaseDataContext db = new CarRentalDatabaseDataContext();
    public ActionResult Index(String cat, String b, String sort)
    {
        String day_hire = "Daily hire rate";
        String man_date = "Manufacturing date";
        string man_n = "Manufacturer's name";

        var s = db.Vehicles.Where(c => c.Model.body_style == b)
             .Select(u => new CarClassViewModel { 
                 manur_name = u.Manufacturer.manufacturer_name, 
                 model_code = u.model_code,
                 daily_hire_rate = u.daily_hire_rate,
                 manur_date = u.manufacturing_date
             })
             .Distinct(); //I don't need repeating data

        //this is for sorting them, but I haven't implemented this in the view yet. 
        if (sort == man_n){s = s.OrderBy(c=>c.manur_name);}
        else if (sort == man_date){s = s.OrderBy(c =>c.manur_date);}
        else if (sort == day_hire){s = s.OrderBy(c => c.daily_hire_rate);}
        else{s = s.OrderBy(c => c.daily_hire_rate);}

        var v = s.Select(u => new CarClassViewModel
        {
            manur_name = u.manur_date,
            model_code = u.model_code,
            daily_hire_rate = u.daily_hire_rate,
        }); //this is for returning values I need

        return View(v); //I've tried View(v.ToList()) as well
    }

Now this returns empty rows in my table. Does it matter that I’m not parsing in data for the method?

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-11T18:40:42+00:00Added an answer on June 11, 2026 at 6:40 pm

    I’m not sure what I’m doing wrong.

    Your data model is very messed up. Even leaving the naming conventions aside, look at your properties:

    public Vehicle manur_name {get; set;}
    public Vehicle manur_date { get; set; }
    public Vehicle daily_hire_rate { get; set; }
    

    The manufacturer name of a car isn’t a vehicle – it’s likely to be a string. The manufacturing date of a car isn’t a vehicle – it’s likely to be a DateTime. The daily hire rate of a car isn’t a vehicle – it’s likely to be a decimal. So your model should look like this:

    public string ManufacturerName { get; set; }
    public DateTime ManufacturingDate { get; set; }
    public decimal DailyHireRate { get; set; }
    

    Get your data model right, and everything else should become a lot simpler. Having said that, this looks pretty suspicious too:

    manur_date = m.model_code
    

    A “date” and a “code” don’t sound like the same thing to me.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have a French site that I want to parse, but am running into
I am currently running into a problem where an element is coming back from
I am trying to understand how to use SyndicationItem to display feed which is
link Im having trouble converting the html entites into html characters, (&# 8217;) i
I'm parsing an RSS feed that has an ’ in it. SimpleXML turns this
I'm trying to decode HTML entries from here NYTimes.com and I cannot figure out
I'm trying to create an if statement in PHP that prevents a single post
I have a view passing on information from a database: def serve_article(request, id): served_article
I ran into a problem. Wrote the following code snippet: teksti = teksti.Trim() teksti
i want to parse a xhtml file and display in UITableView. what is the

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.