Skip to main content

Posts

Showing posts from October, 2013

javascript escape (unescape) pound sign - utf-8 encoding

In UTF-8 encoding, pound sign (£) is two bytes: 0xC2 0xA3. However, if you use javascript escape() function, the output is %A3. In server side, if you use the HttpUtility.UrlDecode("%A3") to decode it,  the result will be three bytes sequence: ef bf bd, which display like  �. In order to get the correct UTF-8  pound character (£), you need to use javascript encodeURIComponent('£') function. The output will be expected %C2%A3.

OData CRUD operations implementation tips

Suppose I have collection of SupplierEntity need to expose as OData: 1. Inherit from EntitySetController < SupplierEnt i ty , int> 2. For getting collections of SupplierEntity object s, override IQueryable < SupplierEnt i ty > Get () method in base class public override IQueryable < SupplierEnt i ty> Get () 3. For getting single SupplierEntity object, override GetEntityByKey(int key) method   protected override SupplierEnt i ty GetEntityByKey ( int key )   4. For creating SupplierEntity object, override both CreateEntity(SupplierEntity entity) and GetKey(SupplierEntity entity) methods protected override SupplierEntity CreateEntity ( SupplierEntity entity ) protected override int GetKey ( SupplierEntity entity )   Note: In CreateEntity method, when the entity has been created in database and the key have been assigned by database, we need to assign this key to entity parameter and return it back to client. 5. For updating SupplierE