I am trying to implements the IUpdatable.
Error 1 'WebRole1.InfoManager' does not implement interface member 'System.Data.Services.IUpdatable.ClearChanges()' All the errors i get are saying that i am not implementing all interface members, but i implements some not all of course. I didn't put the hole code I hope that you can understand.
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)
{
//Implem开发者_如何学运维ented Code
}
}
}
It's an interface, therefore you MUST implement all members - whether you want to, or not.
This error will not go away until you implement the interface in its entirety. You can do what you want within the scope of the method you're implementing, say even raising a NotImplementedException
for instance - but that is your implementation so the compiler is happy.
I won't condone ignorance (you should still learn the hows and whys) but I will offer a tip which may aid in your learning and, if nothing else, future productivity:
From within Visual Studio, when you have the class code file open which is to implement the interface then you can have VS spit out the code for you...
class MyClass : IMyInterface // <- hover mouse and click the drop down that appears
From the drop down you should see the option Implement Interface 'IMyInterface'
, click it and voilà! It will automatically generate the skeletal method bodies for you.
I don't understand what the question is. If you implement an interface, you must implement all methods in that interface. Otherwise the compiler will give an error.
I think the error is clear: you are not implementing all interface members, which is required of course.
精彩评论