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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 13, 20262026-06-13T18:32:07+00:00 2026-06-13T18:32:07+00:00

Question I’m trying something new here with a program I made earlier. In the

  • 0

Question I’m trying something new here with a program I made earlier. In the first program I was able to drag and drop table adapters and use the generic “var” to store query results. Now I’m trying to create a new program that has some separation of code. For example in the first program I had all of the code written in the form.cs file, this time I’d like to create a class to run the queries and return them to the calling class, however, how do you store a query result that contains many types? You cant return a var variable, it must be more specific. I get an error on the select line that reads: “Cannot implicitly convert type’System.Collections.Generic.IEnumerable’ to ‘System.Collections.Generic.IEnumerable;. An explicit conversion exists(are you missing a cast?)

Can some one help me? What is the cast? The first method (public IEnumerable getList()) works as expected its the second method, (public IEnumerable getRecipeInfo(string recipeName)) where I get the error. Here’s my code so far.

namespace recipeDataBase
{
    class Query
    {
        recipiesNewDataSet recipeDataSet = new recipiesNewDataSet();
        recipiesNewDataSetTableAdapters.RecipeTableAdapter recipeTableAdapter = new recipiesNewDataSetTableAdapters.RecipeTableAdapter();
        recipiesNewDataSetTableAdapters.RecipeIngredientTableAdapter ingredientTableAdapter = new recipiesNewDataSetTableAdapters.RecipeIngredientTableAdapter();
        recipiesNewDataSetTableAdapters.RatingTableAdapter ratingTableAdapter = new recipiesNewDataSetTableAdapters.RatingTableAdapter();

        public  Query()
        {

        }

        public IEnumerable<string> getList()
        {
            recipeTableAdapter.Fill(recipeDataSet.Recipe);

            IEnumerable<string> recipeList = (from a in recipeDataSet.Recipe
                                              select a.RecipeName);
            return recipeList;
        }

        public IEnumerable<string> getRecipeInfo(string recipeName)
        {
            recipeTableAdapter.Fill(recipeDataSet.Recipe);
            ratingTableAdapter.Fill(recipeDataSet.Rating);
            ingredientTableAdapter.Fill(recipeDataSet.RecipeIngredient);
            IEnumerable<string> recipeInfo = (from a in recipeDataSet.Recipe
                                              from b in recipeDataSet.Rating
                                              from c in recipeDataSet.RecipeIngredient
                                              where a.RecipeName == recipeName &&
                                              a.RecipeNum == c.RecipeNum &&
                                              a.RatingNum == b.RatingNum
                                              select new { a.RecipeName, a.Nationality, a.Event, a.Source, b.FamilyRating, c.Ingredient });
            return recipeInfo;
        }

    }
}

Thanks in advance for any help!!

  • 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-13T18:32:09+00:00Added an answer on June 13, 2026 at 6:32 pm

    You’re getting an exception because you select an anonymous type in your query but the type of the query variable is IEnumerable<string>. Instead you must either select a string, use the var keyword or a custom class instead.

    If you want to return something useful, i would create a custom class with all of these properties you have selected in the anonymous type, for example:

    public class Recipe
    {
        public String RecipeName{ get; set;}
        public String Nationality{ get; set;}
        public String Event{ get; set;}
        // ...
    }
    

    Then you can return an IEnumerable<Recipe> instead from the method and select instances in the query:

    ...
    select new Recipe(){ RecipeName=a.RecipeName, Nationality=a.Nationality, Event=a.Event,... });
    

    Side-note: I would suggest to use Join instead of Where in the query:

    Why is LINQ JOIN so much faster than linking with WHERE?

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

Sidebar

Related Questions

QUESTION: What am I missing or doing wrong? I'm trying to migrate fully functional
Question is already been asked in title. Here is a code: (function($){ var filter
Question is relevant to this and this ; the difference is, I'd prefer something
Question: I have written a console program that uses the SQL server 2005 web
(Question updated after first comment) int max_size = 20; int h[max_size]; Debugging gives a
QUESTION How can I create a MySQL table so, that a field's default value
Question: How can I give a new user almost all privileges, but still keep
Question i asked earlier along the same lines - jQuery - Selecting a child
Question is how to update string field by concatenating to it? Here is code
Question: I use the bidirectional dicionary class I found here: Bidirectional 1 to 1

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.