Windows手机创建自定义对象到列?

时间:2014-05-28 11:18:59

标签: c# windows-phone-8 windows-phone sql-server-ce create-table

正如问题标题所示,我正在尝试将自定义对象映射到Windows Phone上的db列,我该怎么做?我得到的例外:"无法确定'图层的SQL类型。"

图层是一个自定义对象,存储这个的正确方法是什么,有人可以请我提供一个示例。谢谢

代码:

...

[Table]
    public class Product : INotifyPropertyChanged, INotifyPropertyChanging
    {
        #region ID
        //not autogenerated, this is from the client
        private String _id;

        [Column(IsPrimaryKey = true, IsDbGenerated = false, DbType = "INT NOT NULL Identity", CanBeNull = false, AutoSync = AutoSync.OnInsert)]
        public String Id
        {
            get { return _id; }
            set
            {
                if (_id != value)
                {
                    NotifyPropertyChanging("id");
                    _id = value;
                    NotifyPropertyChanged("id");
                }
            }
        }

        #endregion

 #region Product Layer
        private Layer _productlayer;

        [Column]
        public Layer ProductLayer
        {
            get { return _productlayer; }
            set
            {
                if (_productlayer != value)
                {
                    NotifyPropertyChanging("ProductLayer");
                    _productlayer = value;
                    NotifyPropertyChanged("ProductLayer");
                }
            }
        }

        #endregion

...

 public class Layer
{
    public string name{ get; set; }
    public string des { get; set; }
    public string pos { get; set; }
}

0 个答案:

没有答案