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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 24, 20262026-05-24T17:58:03+00:00 2026-05-24T17:58:03+00:00

I’m trying to persist a very simple username/password combo in WP7 7.1 beta 2

  • 0

I’m trying to persist a very simple username/password combo in WP7 7.1 beta 2 using LINQ to SQL. So far everything works as expected (using the repository/model classes below)

I can create a new database, insert a record and query for that row (and it returns the persisted user no problem). But the next time I spin up the emulator the db context returns false when I exec this expression “db.DatabaseExists()”

Is this normal behavior for the emulator or am I not telling LINQ to persist this between sessions?

Thank you in advance

repository class

public class UserRepository : IDisposable
{
    private readonly UserDataContext context;
    public UserDataContext Context
    {
        get { return context; }
    }

    public UserRepository()
    {
        context = new UserDataContext(UserDataContext.DBConnectionString);
        CreateDatabase();
    }

    private void CreateDatabase()
    {
        if (context.DatabaseExists() == false)
        {
            context.CreateDatabase();
        }
    }

    public User GetByID(int id)
    {
        return context.GetTable<User>().FirstOrDefault(e => e.UserId.Equals(id));
    }

    public User GetByUsername(string username)
    {
        return context.GetTable<User>().FirstOrDefault(e => e.UserName.Equals(username));
    }

    public void Save(User user)
    {
        if (user.UserId > 0)
        {
            context.GetTable<User>().Attach(user, true);
        }
        else
        {
            context.GetTable<User>().InsertOnSubmit(user);
        }

        context.SubmitChanges();
    }

    public List<User> GetAll()
    {
        return context.GetTable<User>().ToList();
    }

    public int Count()
    {
        return context.GetTable<User>().Count();
    }

    public void Dispose()
    {
        if (context != null)
        {
            context.Dispose();
        }
    }
}

model

[Table]
public class User
{
    [Column(IsPrimaryKey = true, IsDbGenerated = true, DbType = "INT NOT NULL Identity", CanBeNull = false, AutoSync = AutoSync.OnInsert)]
    public int UserId { get; set; }

    [Column]
    public string UserName { get; set; }

    [Column]
    public string Password { get; set; }
}

context

public class UserDataContext : DataContext
{
    public static string DBConnectionString = "Data Source=isostore:/User.sdf";

    public UserDataContext(string connectionString) : base(connectionString) { }

    public Table<User> Users;
}
  • 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-24T17:58:03+00:00Added an answer on May 24, 2026 at 5:58 pm

    This is expected behavior.

    The database (and other data) is stored in Isolated Storage on the emulator. The emulator clears Isolated Storage on shutdown (see the first Note in MSDN here), so your database is deleted.

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

Sidebar

Related Questions

I'm making a simple page using Google Maps API 3. My first. One marker
public static bool CheckLogin(string Username, string Password, bool AutoLogin) { bool LoginSuccessful; // Trim
I am trying to understand how to use SyndicationItem to display feed which is
Basically, what I'm trying to create is a page of div tags, each has
I'm new to using the Perl treebuilder module for HTML parsing and can't figure
link Im having trouble converting the html entites into html characters, (&# 8217;) i
That's pretty much it. I'm using Nokogiri to scrape a web page what has
I have just tried to save a simple *.rtf file with some websites and
I have a string like this: La Torre Eiffel paragonata all&#8217;Everest What PHP function
I am reading a book about Javascript and jQuery and using one of the

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.