技术开发 频道

微软WP7本地数据库之Sterling编程技巧

  if (!hasKeys && !hasKeys2)

  {

  _SetupData();

  }

  foreach (var item in App.Database.Query())

  {

  Groups.Add(item.LazyValue.Value);

  }

  foreach (var item in App.Database.Query())

  {

  Contacts.Add(item.LazyValue.Value);

  }

  this.IsDataLoaded
= true;

  }

  
private void _SetupData()

  {

  var groupData
= new List()

  {

  
new GroupViewModel() { GroupName = "GP1"},

  
//others omitted…

  
new GroupViewModel() { GroupName = "GP10"}

  };

  foreach (var item in groupData)

  {

  App.Database.Save(item);

  }

  var contactData
= new List()

  {

  
new ContactViewModel() { GroupId =1,Name="Name11",Email="Name11@hotmail.com",ThumbNail="/WP7SterlingLearning;Component/ThumbNails/11.jpg"},

  
new ContactViewModel() { GroupId =1,Name="Name12",Email="Name12@hotmail.com",ThumbNail="/WP7SterlingLearning;Component/ThumbNails/12.jpg"},

  
//others omitted…

  
new ContactViewModel() { GroupId =10,Name="Name105",Email="Name105@hotmail.com",ThumbNail="/WP7SterlingLearning;Component/ThumbNails/105.jpg"}

  };
0
相关文章