I m 开发一个WCF网络服务,我使用ADO。 查阅数据库的实体净额。
我使用这种方法将一些数据库物体转换成合同物体:
public static List<BlockContract> FormBlocks(int formId)
{
List<BlockContract> blocksList = null;
using (var vAdmEntities = new ADMDatabase.ADMEntities())
{
var blockEntities = from f in vAdmEntities.Form
where f.formId == formId
select f.Block;
if (blockEntities != null)
{
blocksList = new List<BlockContract>(blockEntities.Count());
foreach (ADMDatabase.Block b in blockEntities)
{
BlockContract blockContract = new BlockContract
{
blockId = b.blockId,
name = b.name,
orderInForm = b.orderInForm
};
blocksList.Add(blockContract);
}
}
}
return blocksList;
}
页: 1 栏目:
Cannot convert type System.Data.Objects.DataClasses.EntityCollection<ADMDatabase.Block> to ADMDatabase.Block
我如何解决这一错误?