eTag error in Windows Azure - More Wally - Wallace B. McClure
in

MoreWally.com

Giving people what they want, More Wally. This is the technical and personal blog site of
Wallace B. (Wally) McClure.

This Blog

Syndication

News

Please goy buy 3-4 copies of my book on MonoTouch titled "Professional Android Programming with Mono for Android for .NET/C# Developers." They make great gifts all year round. Plus, I get about $.25 when you buy a copy.

Technical Sites

More Wally - Wallace B. McClure

This blog will have all kinds of posts about Wally McClure. In it, there will be tons of .NET and computer programming posts as well as Wally's views on life in general. As you might guess, this site and blog help you get More Wally in your life. What more could anyone want? iPhone, Android, MonoTouch, MonoDroid, Mobile, HTML5, .NET, ADO.NET, ASP.NET, AJAX, jQuery, jQuery Mobile, ASP.NET AJAX, and Windows Azure............follow me on twitter at Wally

eTag error in Windows Azure

Have you gotten this type of error in Windows Azure:

Since entity type 'ObjectName' has one or more etag properties, If-Match HTTP header must be specified for DELETE operations on this type.

If so, the fix is really simple.  The problem is that you have created a new object and are trying to stuff it back into your entities.

My code to resolve this looks like this:

        public void TwitterEntryDelete(string PartKey, string RowKey)
        {
            TwitterEntry te = new TwitterEntry()
            {
                PartitionKey = PartKey,
                RowKey = RowKey
            };
            AttachTo("TwitterEntries", te, "*"); // <--  The final parameter is the key to solving the problem. You need to tell EF to disregard where this object came from and to put the object into the collection.
            DeleteObject(te);
            SaveChanges();
        } 

By disregarding where the object came from, we can go ahead and tell the system to put the object in our collection(attach) and then operate on the object.

Comments

No Comments
2006 - Wallace B. McClure
Powered by Community Server (Non-Commercial Edition), by Telligent Systems