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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 1, 20262026-06-01T03:01:37+00:00 2026-06-01T03:01:37+00:00

i have the following code snippet. in which i just want to return PartyName

  • 0

i have the following code snippet.
in which i just want to return PartyName as a string.
but i get the error:”Cannot implicity convert type ‘System.Linq.Iqueryable to string”
if i want to return only string then what to do?
please help me.

return objDatabase.FAPARs
.Where(f => (f.PARTY_CODE == "P003"))
.Select(f => f.PARTY_NAME);

  • 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-01T03:01:38+00:00Added an answer on June 1, 2026 at 3:01 am

    An IQueryable<string> represents a query which could return any number of strings. You want one string – so you need to decide what to do in various situations:

    • What do you want to happen if the query has no results?
    • What do you want to happen if the query has one result? (I assume this is simple 🙂
    • What do you want to happen if the query has more than one result?

    The set of methods which allow you to determine all of this are:

    • Single – fail if there isn’t exactly one result
    • SingleOrDefault – fail if there’s more than one result, return null if there are no results
    • First – fail if there are no results, return the first of many
    • FirstOrDefault – return null if there are no results, or the first of many
    • Last – fail if there are no results, return the last of many
    • LastOrDefault – return null if there are no results, or the last of many

    In each case, “fail” means “throw an exception”. (IIRC it’s always InvalidOperationException, at least in LINQ to Objects, but I could be wrong.)

    So if you’re querying by an ID which must exist (i.e. it’s a bug if it doesn’t) then Single is probably appropriate. If you’re querying by an ID which may not exist, then use SingleOrDefault and check whether the return value is null. If you’re not querying by an ID, you probably want to use FirstOrDefault or just iterate over the results.

    (Note that the default value being null is due to this being a query returning strings, and string being a reference type. In general it’s the default value of the element type – so if you had an IQueryable<int>, the default returned would be 0.)

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

Sidebar

Related Questions

I have the following very simple code snippet which is loaded from a separate
i have the following code snippet in my ANT File which compiles my project
I have the following snippet of code which should increment a counter on a
I have following code snippet that i use to compile class at the run
I have following code snippet: class ABC{ public: int a; void print(){cout<<hello<<endl;} }; int
I have the following code snippet where some strings are initialized in the if
I have the following code snippet: using (SPSite site = new SPSite(this.ListAddress)) { using
I have the following code snippet: enum { one } x; enum { two
I have the following code snippet: #ifdef DO_LOG #define log(p) record(p) #else #define log(p)
I have the following code snippet embedded into some of my divs so when

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.