首页 诗词 字典 板报 句子 名言 友答 励志 学校 网站地图
当前位置: 首页 > 教程频道 > 网站开发 > asp.net >

在类名上这样写是啥[Table(Name = "Product")]解决方法

2012-04-14 
在类名上这样写是啥[Table(Name Product)][codeC///]summary/// Business entity used to model a

在类名上这样写是啥[Table(Name = "Product")]
[code=C///] <summary>
    /// Business entity used to model a product
    /// </summary>
    [Table(Name = "Product")
    public class ProductInfo {

        private EntityRef <CategoryInfo> _category;

        /// <summary>
        /// Default constructor
        /// </summary>
        public ProductInfo() { }

        /// <summary>
        /// Constructor with specified initial values
        /// </summary>
        /// <param name="id">Product Id </param>
        /// <param name="name">Product Name </param>
        /// <param name="description">Product Description </param>
        /// <param name="image">Product image </param>
        /// <param name="categoryId">Category Id </param>
        public ProductInfo(string id, string name, string description, string image, string categoryId) {
            this.Id = id;
            this.Name = name;
            this.Description = description;
            this.Image = image;
            this._category = new EntityRef <CategoryInfo>();
            this._category.Entity.Id = categoryId;
        }

        // Properties
        [Column(Name = "ProductId", IsPrimaryKey = true, DbType = "varchar(10)")]
        public string Id { get; set; }

        [Column(Name = "Name", DbType = "varchar(80)")]
        public string Name { get; set; }

        [Column(Name = "Descn", DbType = "varchar(255)")]
        public string Description { get; set; }

        [Column(Name = "Image", DbType = "varchar(80)")]
        public string Image { get; set; }

        [Column(Name = "CategoryId", DbType = "varchar(10)")]
        public string CategoryId { get; set; }

        [Association(IsForeignKey = true, ThisKey = "CategoryId", Storage = "_category")]
        public CategoryInfo Category
        {
            get
            {
                return this._category.Entity;
            }
            set
            {
                this._category.Entity = value;
                value.Products.Add(this);
            }
        }
    }[/code]

[Table(Name = "Product")]
[Column(Name = "CategoryId", DbType = "varchar(10)")]
[Association(IsForeignKey = true, ThisKey = "CategoryId", Storage = "_category")]



这3个都是什么意思呢

前两个难道是在构建一张表结构?还能往里面插数据



[解决办法]
映射到数据库的表,你去看看LINQ TO SQL的相关内容就知道怎么回事了。
[解决办法]
一种反射机制的写法
[解决办法]
这是 Attribute。自行Google下,基本的C#语法。
[解决办法]
http://www.cnblogs.com/dudu/articles/4449.html
[解决办法]

C# code
            Dictionary<List<int>, List<byte>> dicbyte = new Dictionary<List<int>, List<byte>>();            // 前面是个整数数组,表示 List<byte>值的索引,根据索引来指定List<byte>的子数组            List<byte> list = new List<byte> { 1, 2, 3, 4, 5, 6 };            List<int> list1 = new List<int> { 1, 2, 3, 4, 5 };            List<int> list2 = new List<int> { 2, 3, 4, 5 }; 

热点排行