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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 19, 20262026-05-19T21:50:05+00:00 2026-05-19T21:50:05+00:00

I would like to heard what is suitabale solution for this situation. I use

  • 0

I would like to heard what is suitabale solution for this situation.

I use in WPF app Caliburn.Micro framework. I need have acess to SQL Compact DB.
On DB access I use LINQ TO SQL.

For example In view I have comboBox control or listBox control.
I need load items of these controls from DB.

So I create simple class on access to the DB.

[Export(typeof(IDbManager))]
public partial class DbManager : IDbManager
{

    public IList<Spirit_Users> LoadSpiritUsers()
    {
        var result = from u in _dc.Spirit_Users orderby u.Nick select u;
        return result.ToList();
    }
}

I inject this class with MEF to view model class.
On use method from class on DB access in my view model class on load items to comboBox.

[Export(typeof(ILogOnViewModel))]
public class LogOnViewModel : Screen, ILogOnViewModel,
    IPartImportsSatisfiedNotification
{
    [Import]
    internal IDbManager DbManager { get; set; }

    //this property is bind on listbox or comboBox
    public BindableCollection<Spirit_Users> SpiritUsers
    {
        get { return _spiritUsers; }
        set
        {
            _spiritUsers = value;
            NotifyOfPropertyChange(() => SpiritUsers);
        }
    }


    private void ConfigureSpiritUsers()
    {
        //load items from comboBox or listBox
        var users = SettingsDbManager.LoadSpiritUsers();

        //add to the collection which is binded on control in view
        if (users.Count > 0)
        {
            foreach (var user in users)
            {
                SpiritUsers.Add(user);
            }
        }
    }


    protected override void OnActivate()
    {
        ConfigureSpiritUsers();
        base.OnActivate();
    }
}

I don’t know if my solution is correct and the most suitable in scenarion WPF app with MVVVM.

Also I need create CRUD operation from view model class to the DB. For example save some object/data to the database.

Thank for advice.

  • 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-19T21:50:06+00:00Added an answer on May 19, 2026 at 9:50 pm

    This looks fine, in ConfigureSpiritUsers you reference SettingsDbManager, where is this defined? Should this be DbManager instead?

    Really, DbManager is a SpiritUserRepository, and could include your other CRUD operations as methods on the interface and concrete implementation. As long as your view models are always working against abstractions, then that is fine.

    Also, you could populate the SpiritUsers collection in one line with this.SpiritUsers = new BindableCollection(users). I would also make the type of SpiritUsers an IObservableCollection<Spirit_User>, or better still an abstraction of Spirit_User (i.e. ISpiritUser).

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

Sidebar

Related Questions

I have heard a lot about anti patterns and would like to read a
I would like to test my web app in other browsers. I have installed
I would like to use a web server based on Rails. But I have
I've heard of people using this approach and would like to know what the
I have heard about portable applications, and I would like to make some of
I would like to hear what web UI testing tools you have found to
This might be on the discussy side, but I would really like to hear
I basically have an image of a world map and i would like to
I would like to print to a Bixolon SPP-R200 as I've heard, it's one
I would like to know how I can send emails from my web app

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.