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

  • Home
  • SEARCH
  • 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 7971843
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 4, 20262026-06-04T07:43:19+00:00 2026-06-04T07:43:19+00:00

I have a collection: var results = from result in xml.Descendants(ns + GetQuoteResult) select

  • 0

I have a collection:

            var results =
            from result in xml.Descendants(ns + "GetQuoteResult")
            select new SpotPriceModel
            {
                Type = result.Element(ns + "Type").Value,
                Currency = result.Element(ns + "Currency").Value,
                Date = result.Element(ns + "Date").Value,
                Time = result.Element(ns + "Time").Value,
                Rate = (decimal)result.Element(ns + "Rate"),
                Bid = (decimal)result.Element(ns + "Bid"),
                BidTime = result.Element(ns + "BidTime").Value,
                ExpTime = result.Element(ns + "ExpTime").Value,
                DisplayTime = result.Element(ns + "DisplayTime").Value,
                DisplayDate = result.Element(ns + "DisplayDate").Value,
                Ask = (decimal)result.Element(ns + "Ask"),
                AskTime = result.Element(ns + "AskTime").Value
            };

        var spot = results.First();

        return View(spot);
    }

And I have created a model of that collection:

    public class SpotPriceModel
{
    public string Type { get; set; }
    public string Currency { get; set; }
    public DateTime Date { get; set; }
    public DateTime Time { get; set; }
    public decimal Rate { get; set; }
    public decimal Bid { get; set; }
    public DateTime BidTime { get; set; }
    public DateTime ExpTime { get; set; }
    public DateTime DisplayTime { get; set; }
    public DateTime DisplayDate { get; set; }
    public decimal Ask { get; set; }
    public DateTime AskTime { get; set; }
}

I am trying to scaffold a view model of ‘spot’.

But when I compile, I get the following error:

The model item passed into the dictionary is of type 'BD.Models.SpotPriceModel', but this dictionary requires a model item of type 'System.Collections.Generic.IEnumerable`1[BD.Models.SpotPriceModel]'.

The view is expecting the following model type:

@model IEnumerable<BD.Models.SpotPriceModel>
  • 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-04T07:43:20+00:00Added an answer on June 4, 2026 at 7:43 am

    You haven’t specified the type in your Linq query and so have created an anonymous type instead of SpotPriceModel.

             select new SpotPriceModel
            {
                Type = result.Element(ns + "Type").Value,
                Currency = result.Element(ns + "Currency").Value,
                Date = result.Element(ns + "Date").Value,
                Time = result.Element(ns + "Time").Value,
                Rate = (decimal)result.Element(ns + "Rate"),
                Bid = (decimal)result.Element(ns + "Bid"),
                BidTime = result.Element(ns + "BidTime").Value,
                ExpTime = result.Element(ns + "ExpTime").Value,
                DisplayTime = result.Element(ns + "DisplayTime").Value,
                DisplayDate = result.Element(ns + "DisplayDate").Value,
                Ask = (decimal)result.Element(ns + "Ask"),
                AskTime = result.Element(ns + "AskTime").Value
            };
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Say I have a collection of bytes var bytes = new byte[] {0, 1,
I have the following Entity Framework query: var results = from r in db.Results
This doesn't work. var result = from row in grid.Rows where (string) row.Cells[COLUMN_1].Value ==
Following on from a previous question, I have the following code: var results =
I have some code that looks like this: foreach(var obj in collection) { try
I have Collection List<Car> . How to compare each item from this collection with
Lets say I have collection of documents with specified longitude and latitude. type is
for example I have collection foo of documents like that: {tag_cloud:[{value:games, count:10}, {value:girls, count:500}]}
We have a collection of entities of type called Unit , collection of entities
I have created a simple method to retrieve XML output from an HTTPService and

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.