2012-03-16 243 views
0

我有一個問題,從Windows Azure的表存儲回讀更多的問題:與Windows Azure存儲

這裏是我用來檢索表存儲的UserEntity代碼:

TableServiceContext tableServiceContext = new TableServiceContext(storageAccount.TableEndpoint.AbsoluteUri, storageAccount.Credentials); 
tableServiceContext.RetryPolicy = RetryPolicies.Retry(3, TimeSpan.FromSeconds(1)); 
user = (from g in tableServiceContext.CreateQuery<UserEntity>(PazoozaEnums.PazoozaTables.UsersUserFacebookActions.ToString()) 
     where g.PartitionKey.Equals(FacebookUserID) && g.Kind.Equals(PazoozaEnums.TableKinds.User.ToString()) 
     select g).AsTableServiceQuery().Execute().FirstOrDefault(); 

下面是存儲在表存儲中的用戶實體。注意它實際上有每個屬性的值。然而,返回的是空值。或者1/1/0001代表JoinDate字段,0代表整數或長字段。我檢查RowKey和PartitionKey,並且這些正確地作爲實體的一部分返回,但其餘的不是。任何人有任何想法,或者在partitionkey和rowkey正確填充之前遇到此問題,但其餘字段不是?我在32位機器上使用nov 2011 azure sdk,c#mvc3。

AccessToken  String AAADlql9ZBqlMBANM1J30d3cmnM6s1o5MojXyZBP5B3dXNkIweJRZA2fx73klxawRhUn9HZAqBC8Y22YZAtwlKolpep5b7ZCedYYSLmO79E5QZDZD 
AlternativeName  String 
AlternativeProfileLink String 
AlternativeSmallPicture  String 
AlternativeSmallPictureSquare String 
EmailAddress String [email protected] 
JoinDate DateTime 2012-03-16T04:35:01.518053Z 
Kind String User 
Name String PazoozaTest Pazman 
OfflineAccessToken String AAADlql9ZBqlMBANM1J30d3cmnM6s1o5MojXyZBP5B3dXNkIweJRZA2fx73klxawRhUn9HZAqBC8Y22YZAtwlKolpep5b7ZCedYYSLmO79E5QZDZD 
PageAccessToken  String 
PageID Int64 0 
PageSize Int32 50 
ProfileLink  String http://www.facebook.com/profile.php?id=100001771566047 
SmallPicture String http://profile.ak.fbcdn.net/hprofile-ak-snc4/41541_100001771566047_2716161_s.jpg 
SmallPictureSquare String http://profile.ak.fbcdn.net/hprofile-ak-snc4/41541_100001771566047_2716161_q.jpg 
VideoPageSize Int32 100 

這裏是我UserEntity類:

public class UserEntity : KindEntity, IUserEntity 
{ 
    // PartitionKey = UserID 
    // RowKey = (DateTime.MaxValue - DateTime.UtcNow).Ticks.ToString("d19") + Guid.NewGuid().ToString() 

    public UserEntity() : this(null, null) { } 
    public UserEntity(string partitionKey, string rowKey) : base(partitionKey, rowKey, PazoozaEnums.TableKinds.User.ToString()) { } 

    public string Name { get; set; } 
    public long PageID { get; set; } 
    public int PageSize { get; set; } 
    public int VideoPageSize { get; set; } 
    public string EmailAddress { get; set; } 
    public string AccessToken { get; set; } 
    public string PageAccessToken { get; set; } 
    public string OfflineAccessToken { get; set; } 
    public string SmallPicture { get; set; } 
    public string SmallPictureSquare { get; set; } 
    public string ProfileLink { get; set; } 
    public string AlternativeName { get; set; } 
    public string AlternativeSmallPicture { get; set; } 
    public string AlternativeSmallPictureSquare { get; set; } 
    public string AlternativeProfileLink { get; set; } 
    public DateTime JoinDate { get; set; } 
} 

回答

1

既然你還沒有在查詢中指定的RowKey,有可能是你有被退回,而不是現有的「空」行你期待的那一排。

+0

謝謝lucifure,問題是我已經指定「Kind」屬性爲除「User」之外的其他內容。 – 2012-03-16 08:22:39