我正在创建一个使用大约 10 个 ttorage 表的 Azure 应用程序。我想采用最佳实践,但我不确定是否应该只有一个文件包含 dataservicecontext.cs 文件中的所有表,或者是否应该为每个表创建一个不同的文件。在我看来,这两种方式都能达到同样的效果。还有其他人对最佳实践有什么看法吗?
public class ContactDataServiceContext
: TableServiceContext
{
public ContactDataServiceContext(string baseAddress,
StorageCredentials credentials)
: base(baseAddress, credentials)
{
}
public const string ContactTableName = "ContactTable";
public IQueryable<ContactDataModel> ContactTable
{
get
{
return this.CreateQuery<ContactDataModel>(ContactTableName);
}
}
}
namespace NerdDinner.Models
{
public class NerdDinnerDataContext : TableStorageDataServiceContext
{
/// <summary>
/// Define an entry-point into our table. Dinners represents an "EntitySet".
/// </summary>
public DataServiceQuery<Dinner> Dinners
{
get
{
//Create the root of a LINQ query of type Dinner against the table Dinners
return this.CreateQuery<Dinner>("Dinners");
}
}
public DataServiceQuery<RSVP> RSVPs
{
get
{
//Create the root of a LINQ query of type RSVP against the table RSVPs
return this.CreateQuery<RSVP>("RSVPs");
}
}
}
}