【发布时间】:2011-08-16 08:22:35
【问题描述】:
我是使用 WCF 服务的新手,我正在使用 ADO.Net 实体数据模型,将其命名为 -> DogModel.edmx。 Dogs 表有 ID、Name 和 Age。它工作正常。但是,我想了解版本背后的概念。
这是 IDog.cs 的代码,
[ServiceContract]
public interface IDog
{
[OperationContract]
Author GetAuthorById(string authorId);
}
[DataContract]
public class DogType
{
bool boolValue = true;
int id = 0;
string name = string.Empty;
int age = 0;
[DataMember]
public int ID
{
get { return id; }
set { id = value; }
}
[DataMember]
public string NAME
{
get { return name; }
set { name = value; }
}
[DataMember]
public int AGE
{
get { return age; }
set { age = value; }
}
}
这是我放在 Dog.cs 上的代码,
public class Dog : IDog
{
public Author GetAuthorById(string dogId)
{
using (DogEntities pubs = new DogEntities())
{
DogType d = new DogType();
var dog = (from p in pubs.Dogs
where p.Id == dogId
select p).First();
d.ID = author.ID;
d.NAME = author.Name;
d.AGE = author.Age;
return d;
}
}
}
“如果我制作了新版本的服务,那么我只需要公开一个新的结尾”。什么意思,请解释一下?
【问题讨论】:
标签: asp.net wcf webforms ado.net-entity-data-model