我想实现IUpdatable。实施接口错误:类不实现接口成员
错误1“WebRole1.InfoManager”不实现接口成员“System.Data.Services.IUpdatable.ClearChanges()” 我得到的是说我没有实现所有的接口成员的错误,但我实现了一些当然不是全部。我没有把孔码放在希望你能理解的地方。
using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Data.Services;
using Microsoft.WindowsAzure;
using Microsoft.WindowsAzure.ServiceRuntime;
using Microsoft.WindowsAzure.StorageClient;
namespace WebRole1
{
public class InfoManager : IUpdatable
{
private TableServiceContext context;
// To Generate DataConnectionString and svcClient
private TableServiceContext GetContext()
{
//Implemented code
}
public CommentManager()
{
context = GetContext();
}
// To get my table infos
public IQueryable<Info> Infos
{
get
{
return context.CreateQuery<Info>("Infos").AsTableServiceQuery();
}
}
// Creating the resource and cheking the compatibility of the type and do an add Object
public Object CreateResource(string containerName, string fullTypeName)
{
//Implemented Code
}
// Return the instance of the resource represented by the object
public Object ResolveResource(Object resource)
{
return resource;
}
public void SaveChanges()
{
context.SaveChangesWithRetries();
}
public void setValue(Object targetResource, string propertyName, Object propertyValue)
{
//Implemented Code
}
}
}
好吧,如果我只需要一些方法,我可以提出NotImplementedException,这是更快,谢谢。 – 2011-03-18 14:49:16
虽然这当然是正确的方法,但这并不是一个好习惯。作为一个同事,我总是会质疑为什么你没有使用所有的方法来实现一个接口。你基本上是在说谎,除非接口规定这种实现是允许的。 – jdmichal 2011-03-18 14:53:19
如果您想快速查看自动生成的更新。如果你想手动完成,那么定义方法主体并省略任何异常提升会比_adding_'throw'更快。 – 2011-03-18 14:55:42