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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 13, 20262026-05-13T01:52:50+00:00 2026-05-13T01:52:50+00:00

I am using VS2010 B2 and EF4 B2 and trying to use Rhino Mocks

  • 0

I am using VS2010 B2 and EF4 B2 and trying to use Rhino Mocks to mock the entity context generated by EEF.

var context = MockRepository.GenerateMock<SomeDBEntities>();
IObjectSet<TxMode> objectSet = new List<TxMode> { mode }.AsObjectSet();
context.Expect(c => c.TxModes).Return(objectSet);

The problem is that c.TxModes is a property of type ObjectSet<TxMode> whereas I am trying to return an IObjectSet<TxMode> and I get the following compile error:

Error 4 The best overloaded method match for 

'Rhino.Mocks.Interfaces.IMethodOptions<System.Data.Objects.ObjectSet
<Data.Entities.TxMode>>.Return(System.Data.Objects.ObjectSet
<Data.Entities.TxMode>)' has some invalid arguments.

The AsObjectSet extension method comes from here.

Any idea how I can get this to compile?

  • 1 1 Answer
  • 1 View
  • 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-13T01:52:51+00:00Added an answer on May 13, 2026 at 1:52 am

    You cannot do it this.
    Check out the serie of post from Julie Lerman

    1. Agile Entity Framework 4 Repository: Part 1- Model and POCO Classes
    2. Agile Entity Framework 4 Repository: Part 2- The Repository
    3. Agile EF4 Repository: Part 3 -Fine Tuning the Repository
    4. Agile EF 4 Repositories Part 4: Compiled LINQ Queries
    5. Agile Entity Framework 4 Repository Part 5: IObjectSet and Include

    She explains very well how to build the repository pattern with EF4 to let you mock that.
    There are also T4 Template, but that will let you understand how all that works.
    Without the adapted T4 Template, it is still quite a lot of work to have it up and running,
    but I find it a very good exercise. 🙂
    I’m in fact implementing it myself right now.

    Good luck 😉

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

Sidebar

Related Questions

I'm using the Self-Tracking Entities codegen option in EF4 (VS2010 RC), and I'm trying
I am using EF4 in VS2010 and I have the following code: MyEntity entity
Im using EF4 in VS2010, POCO's and the model-first approach. My entity has the
I am getting started with Entity Framework using EF4 in VS 2010 RC. So
I'm using MVC3 VS2010 with EF4.1, I have created my DB using SQL Server
Using VS2010 with an older Win32 C/C++ Project, I'm trying to track down missing
I'm using VS2010 express to create a game built with xna . I'm trying
Using VS2010, I cannot use the VBIDE interop DLL. Could someone please see if
Using VS2010, .NET4.0, MVC3, EF4.1 Code-First I have this POCO entities: public class XBLContent
Using VS2010's find dialog, I'm using the following regex: (?'outer'^div\#.+) input$ . I'm trying

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.