2012-12-30 71 views
0

我是一个小白到.NET和Windows Azure的,并试图遵循本教程:当​​我尝试如下声明一个IQueryable财产 http://msdn.microsoft.com/en-us/wazplatformtrainingcourse_introtowindowsazurelabvs2010_topic2.aspx.NET的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()); 
    } 
} 

我感谢你的帮助。

+0

您是否创建了“C1_Schema”类? –

+0

是的,我确实创建了它 –

+0

显示更多代码,包括声明此属性的类。 –

回答

1

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

移动你的财产的文字,像这样:

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

我建议你试图做一些图书馆特定像在此之前采取一些更基本的C#教程第一。

+0

你是正确的先生。当然,谢谢你 –

+0

一个属性也可以在'struct'里面。接口可以定义非静态属性,但实现不在接口中(它在实现接口的类和结构中)。 –

相关问题