部分类我有这个类的父类:如何继承存储过程调用
public partial class GetStuffResult
{
private int _Id;
private string _Name;
public GetStuffResult()
{
}
[Column(Storage="_Id", DbType="INT NOT NULL")]
public int Id
{
get
{
return this._Id;
}
set
{
if ((this._Id != value))
{
this._Id = value;
}
}
}
[Column(Storage="_Name", DbType="NVarChar(100)")]
public string Name
{
get
{
return this._Name;
}
set
{
if ((this._Name != value))
{
this._Name = value;
}
}
}
}
这是有一个额外的方法的异常相同方法的基类:
public partial class GetStuffResult1
{
private int _Score;
private int _Id;
private string _Name;
public GetStuffResult1()
{
}
[Column(Storage="_Score", DbType="INT NOT NULL")]
public int Id
{
get
{
return this._Score;
}
set
{
if ((this._Score != value))
{
this._Score = value;
}
}
}
[Column(Storage="_Id", DbType="INT NOT NULL")]
public int Id
{
get
{
return this._Id;
}
set
{
if ((this._Id != value))
{
this._Id = value;
}
}
}
[Column(Storage="_Name", DbType="NVarChar(100)")]
public string Name
{
get
{
return this._Name;
}
set
{
if ((this._Name != value))
{
this._Name = value;
}
}
}
}
我之前做过继承,但我完全困惑它将如何在这种情况下工作?我如何继承GetStuffResult,以便我可以使用它的两个方法,而不必在GetStuffResult1中将相同的代码粘贴两次。 如果有人可以举例说明代码,我将会很感激,因为我是.NET 3.5的新手,并且仍然在努力学习它。
非常感谢回答,我还有一个问题。因此,在子类中,我们将删除_Id和_Name。我怎么称呼这些? – NoviceMe 2012-07-25 03:55:46
@NoviceMe,检查编辑答案 – Habib 2012-07-25 04:02:01
非常感谢。我认为这有帮助,我在相同的条件下思考,但这是一个linq查询,我从来没有使用过,它是完全抛弃我。让我试试这个。再次感谢一吨! – NoviceMe 2012-07-25 04:07:22