Entity Framework – Update without Select

This post applies to EF 4.1 and above.

In a recent post I demonstrated how to delete a record from your data source without first selecting it. I’ve found this idea to be most relevant when using MVC. I don’t want a tonne of hidden fields in my form in order to get a complete entity that I can post to my controller, when all I need to delete a record is it’s primary key or id.

Entity Framework – Delete without Select

If my site has been properly developed, I may have a view model which contains only the data which my view needs. My view contains editable fields only. I don’t have a fully populated entity.

Continue reading “Entity Framework – Update without Select”

How to write an EPP client in C#

Extensible Provisioning Protocol(EPP), defined in RFC 5730 is a protocol which is used in the Internet industry for the provisioning of domain names, hosting and related contact details. It is currently not used for much otherwise. It is rare to have to write software to consume an EPP-based webservice, so when I came to do so, I could find little to no examples written for the .NET framework. So I’ll post what I have found here.

The basics are as follows. Messages are sent and received in XML, and generally over TCP or similar transport protocols. All communications must be secured. Details of the message structures can be found at the above link.

Continue reading “How to write an EPP client in C#”

Entity Framework – Delete without Select

This post applies to EF 4.1 and above.

The following technique is applicable to updating as well. But for a more detailed explanation, head over to Entity Framework – Update without Select.

The method used to delete an entry using Entity Framework is DbContext.DbSet.Remove(Object entity), which accepts as it’s single parameter the entity you wish to delete. A subsequent call to .SaveChanges() on your context will perform a delete query on the database.

Continue reading “Entity Framework – Delete without Select”

Load Cross-Domain Javascript Synchronously Using jQuery

When you use a script tag to include Javascript in an HTML document, it’s content is loaded synchronously. This means that the whole script is loaded and executed before the browser continues to process the page. This is very useful, as it means we can load a large script, such as jQuery, and then use it in any subsequent Javascript. Of course, we can’t do anything that amends the DOM until the whole page has loaded, but we can access any variables that the jQuery script sets up, such as it’s global dollar: ‘$’.

Many times we may want to load an external script dynamically, using AJAX. If the script is located within a domain different to yours, it must be retrieved asynchronously, which means it will load and execute in the background whilst script execution continues. jQuery has many handy functions we can utilise to make AJAX requests, and most, if not all, allow you to specify a callback function to be executed when the script has loaded, or failed to load. This doesn’t address the point of this post, but it is great, as we can make sure a script has completely finished loading before trying to use it.

But what if we have some code that has multiple external dependencies? Or what if we have multiple external script files which need to load and execute in a specific order? Ideally we would tell jQuery to load the files synchronously, but it’s not allowed. Maybe that’s because it could hang the browser if a request fails.

Continue reading “Load Cross-Domain Javascript Synchronously Using jQuery”

Inaugural Post

Hello, World.

Here you may find posts about programming, or something else entirely. I don’t know yet. Let’s find out together… bollocks, nobody’s reading this. As if I hadn’t expressed my insanity enough by starting a blog, I’m now talking to myself.

Create a website or blog at WordPress.com

Up ↑