Hello Chris,
I downloaded and debugged you project. When the following line in Default.aspx.cs page is called:
this.messageList.DataSource = context.Messages;
The actual raw xml data returned is:
<entry m:etag="W/"datetime'2011-05-13T15%3A41%3A28.847Z'"" xmlns="http://www.w3.org/2005/Atom" xmlns:m="http://schemas.microsoft.com/ado/2007/08/dataservices/metadata">
<id>http://127.0.0.1:10002/devstoreaccount1/Messages(PartitionKey='a',RowKey='12520969707112181959_81962fd7-db9c-452e-8a96-d3969fe3aeaf')</id>
<title type="text"></title>
<updated>2011-05-13T15:42:11Z</updated>
<author>
<name />
</author>
<link rel="edit" title="Messages" href="Messages(PartitionKey='a',RowKey='12520969707112181959_81962fd7-db9c-452e-8a96-d3969fe3aeaf')" />
<category term="devstoreaccount1.Messages" scheme="http://schemas.microsoft.com/ado/2007/08/dataservices/scheme" />
<content type="application/xml">
<m:properties>
<d:PartitionKey xmlns:d="http://schemas.microsoft.com/ado/2007/08/dataservices">a</d:PartitionKey>
<d:RowKey xmlns:d="http://schemas.microsoft.com/ado/2007/08/dataservices">12520969707112181959_81962fd7-db9c-452e-8a96-d3969fe3aeaf</d:RowKey>
<d:Timestamp m:type="Edm.DateTime" xmlns:d="http://schemas.microsoft.com/ado/2007/08/dataservices">2011-05-13T15:41:28.847Z</d:Timestamp>
<d:Body xmlns:d="http://schemas.microsoft.com/ado/2007/08/dataservices">Pd6x3xTfjBhZWApoYBeXxA==</d:Body>
<d:Name xmlns:d="http://schemas.microsoft.com/ado/2007/08/dataservices">Anonymous</d:Name>
<d:BodyCopy xmlns:d="http://schemas.microsoft.com/ado/2007/08/dataservices">hello</d:BodyCopy>
<d:Seed m:null="true" xmlns:d="http://schemas.microsoft.com/ado/2007/08/dataservices" />
</m:properties>
</content>
</entry>
You can see that there is not a namespace of prefix "d" that in the root element. So for your case, if (dNamespacePrefix != null) is not passing.
You can either revise the code to deal with that case, or how about using reflection instead of directly processing to the raw xml data?
void DataServiceContextEx_ReadingEntity(object sender, ReadingWritingEntityEventArgs e)
{
int KeyVersion = 0;
foreach (PropertyInfo property in e.Entity.GetType().GetProperties())
{
object[] transparentEncryptAttributes = property.GetCustomAttributes(typeof(EncryptAttribute), false);
if (transparentEncryptAttributes.Length > 0
&& property.PropertyType == typeof(string))
{
string propertyValue = (string)property.GetValue(e.Entity, null);
propertyValue = azCrypto.DecryptString(propertyValue, 0);
property.SetValue(e.Entity, propertyValue, null);
}
}
}
Thanks,
Wengchao Zeng
Please mark the replies as answers if they help or unmark if not.
If you have any feedback about my replies, please contact
msdnmg@microsoft.com.
Microsoft One Code Framework