我正在創建一個Azure應用程序,它將使用大約十個存儲表。我想採用最佳做法,但我不確定是否應該只有一個包含dataservicecontext.cs文件中的所有表的單個文件,或者每個表應該有不同的文件。在我看來,兩種方式都能達到同樣的效果。任何人都會對最佳做法有什麼看法?Azure TableServiceContext文件中的許多表或一個表?
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");
}
}
}
}
對不起,上面的代碼的格式。我似乎無法讓它顯示正確。我的意思是顯示兩個文件的功能差不多。我知道後者使用了一個過時的庫,但它仍然顯示在該文件中組合了多個表。 – Gordon 2011-01-31 12:58:59