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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 31, 20262026-05-31T11:30:05+00:00 2026-05-31T11:30:05+00:00

Im trying to get my head around how to work with Linq2Sql in an

  • 0

Im trying to get my head around how to work with Linq2Sql in an MVVM (WP7) application. I think I understand the basics of MVVM, I wrote a few simple testable apps with this pattern, but I am not sure how exactly should I combine it with L2S.

I dont understand a few things. How do I manage the DataContext? Do I have one per app (how else would I track the changes to the entities and propagate them to the DB)? Can I bind directly to the generated model L2S classes? How do I track changes done on the database? Or should I use the repository pattern for that, which sets of event callbacks?

Another thing, to have the VMs easily testable, I use a system of dependency injections and services for some systems of the app. Typical example would be a service for downloading from the internet – to make it testable, I make and interface and two classes that implement it – one for production and one for testing, that returns dummy data. My question is, should I do that for the database access too? Say all L2S queries would be done only inside this this service, shielding the rest of the app from the L2S altogether. Or is is pointless and I should simply have a global DataContext object / singleton and access it from anywhere?

As you can see, I have many question 🙂 I would love to hear your opinions

  • 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-31T11:30:06+00:00Added an answer on May 31, 2026 at 11:30 am

    I think you are on the right track, perhaps follow the repository pattern. If you are comfortable with IOC follow the same path. I would probably look into mocking your data interfaces though, I find it easier in the long run.

    If you are concerned about the db context behaviour it self (eg update tracking) don’t… Not from a unit test perspective. That’s more a full blown integration test (kind of amusing from a phone app perspective but you know what I mean!)

    Remember that there is only one user on your phone and keep the toomstoning in mind.

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

Sidebar

Related Questions

Been trying to get my head around while loops for the last few days
I'm trying to get my head around the whole MVVM thing and binding. I
Im trying to get my head around javascript inheritance and this code doesnt work
I'm trying to get my head around why the following doesn't work. I have
I'm still trying to get my head around how selectors and dynamic typing work
trying to get my head around Feedzirra here. I have it all setup and
Trying to get my head around how to integrate fancyBox with an aspx c#
Just trying to get my head around what can happen when things go wrong
I'm trying to get my head around AMQP . It looks great for inter-machine
I'm trying to get my head around Cappuccino. I'd like my StackOverview peers to

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.