0

我是 .NET 和 windows azure 的菜鸟,并尝试遵循本教程:http: //msdn.microsoft.com/en-us/wazplatformtrainingcourse_introtowindowsazurelabvs2010_topic2.aspx

当我尝试如下声明 IQueryable 属性时:

public IQueryable<C1_Schema> C1_Schema
  {
    get
    {
      return this.CreateQuery<C1_Schema>("C1_Schema");
    }
  }

我得到一个错误:错误预期类,委托,枚举,接口,结构

这是我声明属性的类

public IQueryable<C1_Schema> C1_Schema
  {
    get
    {
      return this.CreateQuery<C1_Schema>("C1_Schema");
    }
  }
    public class context : Microsoft.WindowsAzure.StorageClient.TableServiceContext
    {
        public context(string baseAddress, Microsoft.WindowsAzure.StorageCredentials     credentials)
      : base(baseAddress, credentials)
         { }
    }

C1_Schema 类:

public class C1_Schema : Microsoft.WindowsAzure.StorageClient.TableServiceEntity
{

    public String fname { get; set; }
    public String lname { get; set; }
    public double salary { get; set;}


    public C1_Schema()
    {
        PartitionKey = DateTime.UtcNow.ToString("MMddyyyy");
        // Row key allows sorting, so we make sure the rows come back in time order.
        RowKey = string.Format("{0:10}_{1}", DateTime.MaxValue.Ticks - DateTime.Now.Ticks, Guid.NewGuid());
    }
}

我感谢您的帮助。

4

1 回答 1

1

您正在尝试在类之外声明该属性。在 C# 中,一切都必须在一个类中。

移动属性的文本,如下所示:

public class context : Microsoft.WindowsAzure.StorageClient.TableServiceContext
{
  public IQueryable<C1_Schema> C1_Schema
  {
    get
    {
      return this.CreateQuery<C1_Schema>("C1_Schema");
    }
  }
}

我建议您先学习一些更基本的 C# 教程,然后再尝试做类似这样的特定库。

于 2012-12-30T17:42:27.933 回答