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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 2, 20262026-06-02T10:06:26+00:00 2026-06-02T10:06:26+00:00

I am getting an error : i am using entity framework, wcf. Error:cannot implicitly

  • 0

I am getting an error : i am using entity framework, wcf.

Error:cannot implicitly convert type System.linq.iorderedQueryable<xDataModel.Info> to System.Collection.Generic.List<xServiceLibrary.Info>

Below are my code:


WCF Service:

namespace xServiceLibrary
{
    public List<Info> GetScenario()
            {
                xEntities db = new xEntities();
                 var query = from qinfo in db.Infoes
                                select qinfo;

                  //return query.Cast<Info>().ToList(); (not working)
                  //return query.toList(); (not working)
                    return query;
       }
}

Interface:

namespace xServiceLibrary
{
     [OperationContract]
            List<Info> GetScenario();
}

Class:

namespace xServiceLibrary
{
       [DataContract]
        public class Info
        {
            [DataMember]
            public int Scenario_Id;

            [DataMember]
            public string Scenario_Name { get; set; } 

            [DataMember]
            public string Company_Name { get; set; } 
        }
}

update:(2)
I have two class library files.
One is xDataModel namespace in which i have created xmodel.edmx file.
second is xServiceLibrary namespace where i am implementing Wcf Service.
i have attached the xDataModel.dll file in my xServiceLibrary so that i could query my EF Model.

i am not able to understand the concept. any help would be appreciated.

  • 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-02T10:06:28+00:00Added an answer on June 2, 2026 at 10:06 am

    The problem is that you have two different classes, both called Info, both in scope at the time you run your query. This is a very very bad thing, especially if you thought they were the same class.

    If DataModel.Info and ServiceLibrary.Info are the same class, you need to figure out why they are both in scope at the same time and fix that.

    If they are different classes, you need to be explicit about which one you are trying to return. Assuming that your EF model includes a set of DataModel.Info objects, your options there are:

    1. Return a List<DataModel.Info> which you can get by calling query.ToList()
    2. Return a List<ServiceLibrary.Info> which you can get by copying the fields from your DataModel.Info objects:

      var query = from qinfo in db.Info
              select new ServiceLibrary.Info
              {
                Scenario_Id = q.Scenario_Id,
                Scenario_Name = q.Scenario_Name
                Company_Name = q.Company_Name
              };
      
    3. Return something else, such as your custom DTO object, similar to #2 but with only the specific fields you need (e.g. if ServiceLibrary.Info is a heavy object you don’t want to pass around.

    In general, though, your problem is centered around the fact that the compiler is interpreting List<Info> as List<ServiceLibrary.Info> and you probably don’t want it to.

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

Sidebar

Related Questions

I am getting an error while using the Entity Framework and C#. I am
I'm getting below error while updating two tables using entity framework - Object with
I'm getting an error when using Entity Framework - Code First in the following
I am getting this error when using Entity Framework 4.1 code first. I can
I am getting timeouts using the Entity Framework (EF) when using a function import
We are getting a SecurityException when using Entity framework on godaddy. The entity has
Anyone getting this error when using the new free chart controls MS bought from
I am getting a strange error using jQuery 1.3.2 and Firefox. I have created
I have installed the android SDK but I’m getting an error when using a
I am getting following error message when using Doctrine ORM in Codeigniter. ( !

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.