以二进制方式存储对象到数据库
2010-09-30 21:06:56 来源:WEB开发网其中宠物MyPet属性就是一个复杂类:
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Runtime.Serialization;
namespace TestBinaryObjectSerializedIntoDatabase
{
[Serializable()]
public class Pet
{
private Guid id = Guid.NewGuid();
private string name;
private double weight;
/// <summary>
/// 构造函数
/// </summary>
/// <param name="id"></param>
public Pet(Guid id, string name)
{
this.id = id;
this.name = name;
}
/// <summary>
/// Id
/// </summary>
public Guid Id
{
get { return id; }
}
/// <summary>
/// 名字
/// </summary>
public string Name
{
get { return name; }
set { name = value; }
}
/// <summary>
/// 体重
/// </summary>
public double Weight
{
get { return weight; }
set { weight = value; }
}
}
}
更多精彩
赞助商链接