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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 16, 20262026-05-16T05:38:45+00:00 2026-05-16T05:38:45+00:00

I have a method that contains the following Linq to SQL code: public List<L2SBusinessEntities.Report.MesReport>

  • 0

I have a method that contains the following Linq to SQL code:

    public List<L2SBusinessEntities.Report.MesReport> GetListForReportTree(MESProductionDatabase database)
    {
    byte[] byteArray = new byte[1];
    var results =
        from report in database.MesReport
        select new { report.MesReportID, 
            report.ParentID, 
            report.ReportTitle, 
            report.ReportName, 
            report.DatabaseServer, 
            report.DatabaseName, 
            report.Login, 
            ReportFile = byteArray };

    return (List<L2SBusinessEntities.Report.MesReport>)results;
    }

I’m getting an unable to cast error in trying to cast ‘results’ to the type shown in the return statement. Should I be able to do this? An L2SBusinessEntities.Report.MesReport entity looks as follows:

int MesReportID
int ParentID
string ReportTitle
string ReportName
string DatabaseServer
string DatabaseName
string Login
byte[] ReportFile
  • 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-05-16T05:38:46+00:00Added an answer on May 16, 2026 at 5:38 am

    Your method does not need casting. You can use the following code to return List of your objects:

    public List<L2SBusinessEntities.Report.MesReport> GetListForReportTree(MESProductionDatabase database)
            {
            byte[] byteArray = new byte[1];
            var results = (
                from report in database.MesReport
                select new L2SBusinessEntities.Report.MesReport { 
                    MesReportID = report.MesReportID, 
                    ParentID = report.ParentID, 
                    ReportTitle = report.ReportTitle, 
                    ReportName = report.ReportName, 
                    DatabaseServer = report.DatabaseServer, 
                    DatabaseName = report.DatabaseName, 
                    Login = report.Login, 
                    ReportFile = byteArray }).ToList();
    
            return results;
            }
    

    update ————-

    another option for your query:

    public List<L2SBusinessEntities.Report.MesReport> GetListForReportTree(MESProductionDatabase database)
            {
            byte[] byteArray = new byte[1];
            var results = (
                from report in database.MesReport
                select new { 
                    MesReportID = report.MesReportID, 
                    ParentID = report.ParentID, 
                    ReportTitle = report.ReportTitle, 
                    ReportName = report.ReportName, 
                    DatabaseServer = report.DatabaseServer, 
                    DatabaseName = report.DatabaseName, 
                    Login = report.Login, 
                    ReportFile = byteArray })
            .AsEnumerable()
            .Select(c => new L2SBusinessEntities.Report.MesReport{ 
                    MesReportID = c.MesReportID, 
                    ParentID = c.ParentID, 
                    ReportTitle = c.ReportTitle, 
                    ReportName = c.ReportName, 
                    DatabaseServer = c.DatabaseServer, 
                    DatabaseName = c.DatabaseName, 
                    Login = c.Login, 
                    ReportFile = c.ReportFile }).ToList();
    
            return results;
            }
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have a method that contains the following (Java) code: doSomeThings(); doSomeOtherThings(); doSomeThings() creates
I have a C# string object that contains the code of a generic method,
I have a data type that contains a set and a method that expects
I have a class, that contains a struct. I have a method on the
I have a class that contains this class method: def self.get_event_record(row, participant) event =
I have an interface that contains a single method called ListAll() using System.Collections.Generic; namespace
I have my main application delegate which contains a method that returns an object.
I have the following method: public IEnumerable<Foo> GetFoo(int x, string y) { return from
I have the below LINQ method that I use to create the empty EmploymentPLan
I have the following query that receives a list of ints as a parameter:

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.