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 9118221
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 17, 20262026-06-17T05:05:39+00:00 2026-06-17T05:05:39+00:00

I have the following method: public static object GetBarChart(int dataValue) { using (var myEntities

  • 0

I have the following method:

public static object GetBarChart(int dataValue)
{
using (var myEntities = new i96X_dataEntities())
{
  var myValues = (from values in myEntities.PointValues
                  where values.PointID == dataValue
                  select new
                  {
                     values.DataTime,
                     values.DataValue
                  }).ToList();
  }
  if (myValues.Count() != 0)
  {
    return myValues;
  }
  return null;
}

I can only return it as an object, because I can’t work out how to define it as its type. When I debug it tells me the return type is:

{System.Collections.Generic.List<<>f__AnonymousType2< System.DateTime,double>>}

But I can’t work out how to define that.

I have defined a class:

public class BarChart
{
  public DateTime Time { get; set; }
  public double Value { get; set; }
}
public class BarList
{
  public List<BarChart> BarL { get; set; } 
}

I presume that’s correct. But if I now use BarList as my return type the compiler reads:

Cannot convert expression type ‘System.Collections.Generic.List<{DataTime:System.DateTime, DataValue:double}>’ to return type BarList’

I think the answer is just to define BarChart, then return List< BarChart>.

Thanks for any assistance.

  • 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-17T05:05:41+00:00Added an answer on June 17, 2026 at 5:05 am

    The function returns collection of Anonymous types. The anonymous type is defined in the LINQ expression.

    If you know the type of which the PointValues collection in the DB is composed of then you can return directly that type.

    If you have a class called for instance Point than change Anonymous constructor in the LINQ expression to a concrete one:

    select new Point { Time = values.DataTime, Value = values.DataValue }
    

    In that case your method will return a list of points. IList<< Point >>

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

Sidebar

Related Questions

I have the following method public static void SerializeToXMLFile(Object obj,Type type, string fileName) {
I have the following method in an App_Code/Globals.cs file: public static XmlDataSource getXmlSourceFromOrgid(int orgid)
That is, I have a method such as the following: public static int CreateTaskGroup(string
I have the following method signature: public static void InvokeInFuture(Delegate method, params object[] args)
I have the following method: public static T ExecuteScalar<T>( string query, SqlConnection connection, params
I have the following method declaration: public static bool SerializeObject<T>(string filename, T objectToSerialize){ I
On my front end, I have following functions: method to encrypt: public static string
I have the following method: public object[] GetEventsByUser(DateTime start, DateTime end, string fullUrl) The
I have the following method in an external class public static void DoStuffWithAnimals(IDictionary<string, Animal>
I have the following code : public class Main { public void method(Object o)

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.