Internet connection speed in Iran is everyone’s problem these days

I really can say this: “The World is required an internet connection to move on”. Nearly all people who work with computers/mobile-based devices are working online so the internet is something necessary.

Old 33.6 modemI can remember days that I was using Dial-Up connections in order to connect to the internet. The process for connecting to the internet was so boring and also the internet connection’s speed was so slow (about 33.600 kbps since I can remember). After sometime, Modern Dial-Up modems showed up with 56 kbps; and it was a huge move since the first generation of modems, in my opinion. 56kbps V92 US ROBOTIC ModemFor about 5 year or so, Iranian people had accessed the internet using 56 kbps modems and after that, the first company in Iran introduced ADSL service to the market. I think this was the most important event in internet service providing in Iran. They were providing 128kbps internet for the commercial use and 64kbps for home use. But the problem was their price that was so expensive. Only a few range of people in Iran could bought those services and most of the people trying to get used to traditional dial-up connections because they couldn’t afford ADSL.

Today's Adsl modemAs the world grows, the internet grows side-by-side and it’s a fact that these days every single person needs a high speed internet connection for doing everyday tasks.

In developed countries, most people can’t live without the internet because tasks are becoming online and people are preferred to stay behind their desks and get their jobs done.

The quality of connection is also matters. People want to access the internet easily. They want to access their websites as fast as possible and one of the most important factors is SPEED!

Unfortunately, the internet connection’s speed is awful in Iran and also the government has limited the internet connection’s speed for home use. Currently, they offer 128kbs connections for home and up to 2Mbps for commercial use. The price of 2Mbps connection is so expensive, by the way! As far as I know, it’s about 210 USD per month! I know that the limitations for internet connections have relationships with politics in Iran but this speed I talked about is nothing compared other countries.

People want to see more of the web and they need more speed of internet connection. I think government should do something for internet connection’s speeds and find a solution. In my opinion, the minimum speed for internet speed is 2Mbps for home use!

Some of the disadvantages of WCF Data Services

ODataSince I’m working with WCF Data Services as my project’s data source, I’ve experienced some cons in WCF data services and going to share with you now. I hope Microsoft find a solution for these:

  • Some of lambda expressions don’t work on WCF Data Services. I want to list a few of these. (In some cases, lambda expressions can be replaced with old style LINQ but I prefer to use lambda):
  • Sub-queries are not supported in WCF data services.
  • Debugging in WCF data services is such a pain in the neck.
  • Application security. Implementing role based security in WCF data services is very difficult as I’m currently planning to implement a role based security in my application.

Maybe there are solutions for any of the items above but I don’t know about them. If you really know, update this post by sending comments.

A brief overview of OData and WCF data services

People all around the world want to share data. They want to share their interests with others. Companies want to share data too. For example, EBay wants to distribute data of latest products and interests to the web and enable other companies to use that data in their own websites. There were ways to do that:

  • RSS/ATOM feeds.
  • XML Web services.

But each of the items above has their own problems and both of them have lots of limitations. In fact, there is no way to query the source’s database. In the EBay example, it’s impossible to select some data with specific parameters except the EBay has been developed some methods in order to that but it’s not enough in some cases, as you know.

But there’s a new way to distribute data and that’s OData!

OData is the short form of “Open Data Protocol” which is a new standard way for distributing data. The result of OData is standard XML so you can access to it using any programming language/tools. Here’s the OData definition from its official website:

The Open Data Protocol (OData) is a Web protocol for querying and updating data that provides a way to unlock your data and free it from silos that exist in applications today. OData does this by applying and building upon Web technologies such as HTTP, Atom Publishing Protocol (AtomPub) and JSON to provide access to information from a variety of applications, services, and stores. The protocol emerged from experiences implementing AtomPub clients and servers in a variety of products over the past several years.  OData is being used to expose and access information from a variety of sources including, but not limited to, relational databases, file systems, content management systems and traditional Web sites.

Companies have started to use OData too; for example you can access Netflix’s latest movies and use them in your application using OData! In order to do so, visit http://odata.netflix.com.

The table below shows the libraries which currently support OData:

OData Currently supported programming languages' library

 

You can download any library you want depend on what programming language you’re working with. As you can see in the table above, .NET Framework 3.5 SP1 and 4 is supported. In order to use OData in .NET 3.5 SP1, you have to download and install Data Service Support for .NET Framework 3.5 SP1 and then start working with but if you’re developing your application based on .NET Framework 4, you don’t need anything at all because Data Services is supported built-in.

In order to get more information about OData standards and documentations, you can checkout: http://odata.org.

WCF Data Services

WCF Data Services is the implementation of OData in .NET Framework. Hopefully, Microsoft has done a great job on this and it’s very easy to use. Data Services is not dedicated to databases; in fact it’s all about entities. You can build any entities and access it via Data Services. For example you can create an Entity Framework 4 entity and the access it via a Data Service. It’s the same story for LINQ to SQL, XML, etc.

As an example, I decided to create a Data Service for my EF 4 database model. Here are steps you can create a Data Service:

  1. As I mentioned, I preferred to use LINQ to Entity in my project so first you need to do is to create a database model by creating an ADO.NET Entity Data Model.
  2. After creating the database model, it’s time to create the data service. There’s nothing else to do! If you want to create a data service, you can add new WCF Data Service file to the project.
    Adding a WCF Data Service
  3. After a WCF Data Service file to your project, Visual Studio will create a .NET class which is inherited to DataService class. The DataService class in a generic class so you have to assign a data source to it. If you’re using EF, all you need is to type the name of your entity. For example “NorthwindEntities”.
    wcf-data-service-class-view
  4. Then you need to set permissions for the data service. The WCF data service that is created by Visual Studio contains a static InitializeService method that has an input parameter as a DataServiceConfiguration class which includes some methods in order to set permissions for the data service. The most important method for setting permissions is SetEntitySetAccessRule that you can set access rule for your entity. Here’s an example:
  5. As you can see, SetEntitySetAccessRule accepts two parameters. The first parameter is the name of the entity as string and the second parameter is the entity set rights. In the example above, the entity set rights is set to AllRead which means that users can only read from this entity. If you want to allow users to read and also write data using your service, you can set the entity rights to “All”.

Now your service is ready to use! It’s that easy! You can add your service to another application as same as adding a WCF service and use it. But the difference is that the service is using OData to publish the data. Also you can use LINQ expressions to access whatever you want!

Unfortunately, some of the lambda expressions are not supported by WCF Data Services. For instance, you can’t use Single method like this:

var x = myService.Table.Single(p=>p.Id == 1);

You have to use Single like this:

var x = (from i in myService.Table where i.Id == 1 select i).Single();

I hope Microsoft fix this problem as soon as possible.

I’ll post about WCF Data Service in my future posts but for now if you want to know more about it, you can check out WCF Data Service Client Library in MSDN