Windows Phone 学习 创建和使用数据库
2015-05-10 00:26
363 查看
using (MyDataContex dc = new MyDataContex()) { if (dc.DatabaseExists() == false) { dc.CreateDatabase(); System.Diagnostics.Debug.WriteLine(DateTime.Now.ToLongTimeString() + " 数据库创建完成。"); } else { System.Diagnostics.Debug.WriteLine(DateTime.Now.ToLongTimeString() + " 数据库已经存在。"); } }
public class TestEntity : INotifyPropertyChanging, INotifyPropertyChanged { private string _cityName; /// <summary> /// 公共属性,对应于表中的列 /// </summary> [Column] public string CityName { get { return this._cityName; } set { if (this._cityName != value) { OnPropertyChanging("CityName"); this._cityName = value; OnPropertyChanged("CityName"); } } } public event PropertyChangingEventHandler PropertyChanging; // 引发PropertyChanging事件 protected void OnPropertyChanging(string propertyName) { if (PropertyChanging != null) { PropertyChanging(this, new PropertyChangingEventArgs(propertyName)); } } public event PropertyChangedEventHandler PropertyChanged; // 引发PropertyChanged事件 protected void OnPropertyChanged(string propertyName) { if (PropertyChanged != null) { PropertyChanged(this, new PropertyChangedEventArgs(propertyName)); } } } /// <summary> /// 从DataContext派生的类 /// </summary> public class MyDataContex:DataContext { /// <summary> /// 连接字符串 /// </summary> public const string CONNECT_STRING = "Data Source='isostore:/db.sdf';Password='123456'"; /// <summary> /// 构造函数 /// </summary> public MyDataContex() : base(CONNECT_STRING) { } /// <summary> /// 公共属性,对应于数据库中的表 /// </summary> public Table<TestEntity> MyTestEntity; }
相关文章推荐
- Windows Phone 7 不温不火学习之《使用Expression Blend 创建应用程序栏》
- Windows Phone 7 不温不火学习之《使用Expression Blend 创建应用程序栏》 推荐
- Lucene学习之一:使用lucene为数据库表创建索引,并按关键字查询
- Android学习之创建和使用数据库
- 【android学习】_如何创建一个android下可以使用的数据库
- 一步步学习SPD2010--第七章节--使用BCS业务连接服务(2)--创建数据库外部数据源
- 一步步学习SPD2010--第七章节--使用BCS业务连接服务(2)--创建数据库外部数据源
- Android学习---如何创建数据库,SQLite(onCreate,onUpgrade方法)和SQLiteStudio的使用
- SQL学习记录2 创建和使用数据库(weiwancheng)
- 基于CentOS的Mysql学习补充二--使用Shell创建数据库
- 基于CentOS的MySQL学习补充三--使用Shell批量创建数据库表
- Android(java)学习笔记245:ContentProvider使用(银行数据库创建和增删改查的案例)
- 使用sqlyog学习mysql中怎样创建用户、数据库、表
- 基于CentOS的MySQL学习补充三--使用Shell批量创建数据库表
- 【Java学习】使用泛型和反射 创建通用的数据库查询方法
- SQL Server学习笔记1:如何使用软件以及创建第一个数据库
- 了解 oracle使用DataBase Configuration Assistant创建、删除数据库
- 使用Hibernate 创建数据表时,如何使数据库中的字段的长度和Hibernate映射的长度相等呢?
- [转] Oracle学习之创建数据库(新建实例)
- ionic学习使用笔记(一) 版本更新及创建项目时遇到的问题解决