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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 27, 20262026-05-27T01:35:18+00:00 2026-05-27T01:35:18+00:00

For now I did not use MVP and I tried the long conversation pattern

  • 0

For now I did not use MVP and I tried the long conversation pattern like this:

private void SaveItem(object sender, EventArgs e)
{
    using (var transaction = _businessTransactionFactory.Create())
    {
        var currentMobileDevice = GetCurrentMobileDevice();

        if (currentMobileDevice.Id == Guid.Empty)
        {
            transaction.MobileDeviceRepository.Save(currentMobileDevice);
        }
        else
        {
            transaction.MobileDeviceRepository.Update(currentMobileDevice);
        }

        transaction.Commit();
        LoadData(transaction);
    }
}

private MobileDevice GetCurrentMobileDevice()
{
    return (MobileDevice)MobileDevicesBindingNavigator.BindingSource.Current;
}

Problems I encountered:

  • I am always have to work with detached entities.
  • Working with detached entites forces EntityFramework to update ALL columns instead of those that changes:

    public void Update(T entity)
    {
        if (_objectContext.ObjectStateManager.GetObjectStateEntry(entity).State == EntityState.Detached)
        {
            _objectSet.Attach(entity);
            _objectContext.ObjectStateManager.ChangeObjectState(entity, EntityState.Modified);
        }
    }
    

How do you handle the context in a windows forms application?

What are pros and cons of both?

  • 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-27T01:35:19+00:00Added an answer on May 27, 2026 at 1:35 am

    Typical scenario is new context per presenter where presenter can handle more than one view in case of different views on the same data. There is very nice article about this in MSDN magazine. It targets NHibernate’s session but EF’s context management should follow the same approach to solve exactly the problems you are encountering with detached entities.

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

Sidebar

Related Questions

I have a project that originally did not use ajax. Now I want to
This may seem like a very basic question but I did not seem to
I use the following throughout the project and until now did not notice an
first is the disclaimer, I did not design the database I am now supporting
I am the only developer of a software project. I did not use any
Just could not get this one and googling did not help much either.. First
First I'm not mad, because I use MVVM in WinForms-) I know about MVP
I did not use SQL CE 3.5 for Windows Mobile as I need to
On my website I did not wan't to use those distorted text CAPTCHAS. So
So I had this code, and it did not work: for (NSDictionary *item in

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.