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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 28, 20262026-05-28T07:52:15+00:00 2026-05-28T07:52:15+00:00

In order to test a method that uses a stored procedure, a fake method

  • 0

In order to test a method that uses a stored procedure, a fake method has been created. This method is to return a list of ints.

Something like this …

    public virtual ObjectResult<Nullable<int>> available_IDs( ... )
    {
        List<int?> fakeAvailableIDList = new List<int?>();
        fakeAvailableIDList.Add(1);
        fakeAvailableIDList.Add(2);
        fakeAvailableIDList.Add(3);

        ObjectResult<Nullable<int>> result = fakeAvailableIDList.All(m => m > 0);
        return result;
    }

which fails with

Cannot implicitly convert type 'bool' to 'System.Data.Objects.ObjectResult<int?>'

tried (amoungst other things)

ObjectResult<Nullable<int>> result = fakeAvailableIDList.All(m => m > 0);

which gives

Cannot implicitly convert type 'System.Collections.Generic.List<int?>' to 'System.Data.Objects.ObjectResult<int?>'

how can I get a List<> into ObjectResult ?

  • 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-28T07:52:16+00:00Added an answer on May 28, 2026 at 7:52 am

    The line

    fakeAvailableIDList.All(m => m > 0);
    

    returns a boolean because .All returns True or False depending on whether or not all elements in the collection meet the specified condition.

    So, a variable of type ObjectResult can’t be set to a variable of type Bool.

    The ObjectResult and ObjectResult<T> types have hidden constructors, which means you can’t create instances at will. Also, the ObjectResult<T> type is sealed, which means it can’t be extended. So, you might be out of luck if you’re looking for an easy way to create an ObjectResult from an Enumerable.

    The easiest thing to do, I think, would be to change the type used by the method you’re trying to test. So, if that method has the signature:

    void Foo(ObjectResult<int?> result);
    

    Change it to:

    void Foo(IEnumerable<int?> result);
    

    That will allow you to create a fake collection with which the method can be tested, and you’ll still be able to pass the method an ObjectContext<int?> type because ObjectContext<int?> extends IEnumerable<int?>.

    • 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 I'm trying to unit test that uses a query
If there are several methods in the test class, I found that the order
I'm trying to test an Order entity method called AddItem and I'm trying to
I've been looking at ways people test their apps in order decide where to
So i am trying to do this Order.find :all, :conditions => org = 'test
I have 1 unit test method that needs several parameters. I would like to
I've been looking for a method that operates like Arrays.equals(a1, a2) , but ignoring
What is the correct way to unit test a method that returns a sequence
In a school assignment I'm supposed to complete a method that should return an
Okay, the following link has a warning that the discussion uses unsupported and undocumented

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.