A Brave new world, a different point of view. We give you the courage to make the web work.
The web is a scary place. A place where many a might man has fallen. We help, encourage, and promote you and your website, so that your website and business will go where no website has gone before.
Get great information, articles, blogs about Programming, website development and web design. Things like C#, Visual Studio, AJAX, Linq, Cascading Style Sheets, Content Management Systems, Search Engine Optimisation and Marketing, Web site publishing and internet marketing. This might all seem foreign to you. Stick with us and it will soon become second nature.
Finding out what the most popular programming language is and or what the trend is will put you in good stead whether you are staring out or a seasoned programmer.
Finding what the latest trends are is also a good investigative method when planning a new project. This will give you a good indication as to what is available, what others are using, as well as what the long term trends are. The last thing you want is to use a language that might be the in thing today, but completely falls off the cliff into the programming black hole tomorrow.
Tiobe is a popular site for ranking programming languages. Tiobe bases its rankings on world-wide availability of skilled engineers, courses and third party vendors. Rankings are not about the best programming language or the language in which most lines of code have been written. Tiobe uses Google, MSN and Yahoo! search engines to measure the Web "chatter" and hence the popularity of each programming language.Below is their latest list, as of this writing, ranked by popularity, of the most popular programming languages in use.
I did a post previously, in 2009, on the most popular programming language. The most interesting thing to note is the rise of Objective C. This is probably attributed to everything iPhone and iPad, and the apps and games for such. The other interesting thing is the drop of such popular languages as PHP, Visual Basic and Python. Also note the steady rise of C#. But still the kings of the pile and jostling for top honours are still C, C++ and Java.
Would the likes of these trends actually influence you in your programming language decision, or are you still fixed in your ways?
Finally bought an Apple product. An Apple iPad mini to be exact. My wife wanted one so much. I'm not much of an Apple fan, but caved in against my better judgement and bout the Apple iPad mini.
The apple iPad and the iPad mini is a very sleek and attractive device. Owning an iPad or perhaps any Apple product is much of a fashion statement as owning a Gucci handbag or a Carducci suit. Alongside what is advertised as a great product, there is the promise of hundreds of thousands of apps, games and music. However, owning an Apple product in South Africa or any so called third world states, or in fact any Apple product such as the iPad and iPad mini is completely useless. Reason being that the Apple South African store is so restrictive that you cannot download about 80%-90% of the apps, games, movies and music.
Cannot Download Apps and Games
Yes there are apps and stuff to be downloaded to your new iPad from the South African store. But not as many as you might expect, and certainly not the top apps and games that are normally available in the US and Europe. Take Angry Birds for example. Angry Birds, the paid version as well as the free version is not available on the South African Apple app store. The only thing available for Angry Birds on the South African Apple store are Cheat Sheets and Walk through's. What good is that if you don't have and cannot get the game?
Doing and internet search on this issue, I find thousands and hundreds of thousands of similar issues and complaints. Yet, nothing is done about it. The just of the outcome of all this is that Apple blames the FPB (Film and Publications Board), the FPB blames Apple. But nothing is done about it. At the end of the day we are left with literally a white elephant. A product that is of no use to us because we cannot get the apps that we need. Why buy an Apple iPad if you are not going to use the apps that would normally be available for it. It just becomes a very expensive paper wait.
A Work Around
As with anything there are various work arounds available. Just do an internet search to find hundreds of work arounds. Solutions range from Jail-breaking to fake US Apple ID's. Most of these are in the true sense illegal and some could actually cause more damage to the device. Also some work and other do not. I would suggest proceeding with caution. You could be wasting your money and even cause damage to you iPad.
But why should we go through the trouble and hassle of finding work arounds. The thing should just work as advertised. Currently there are not hundreds of thousands of apps and games available. Thousands maybe at best.
Angry and Disappointed
Bottom line is that I am angry and disappointed. I feel cheated and abused. Lied to and defrauded. Certainly will not by an Apple product again. This circular blaming game will not cut it either. I do not care who is at fault. I just want to have a fully working product. If it is a Publications board thing, then there should be warnings when I buy the product so that I can make an informed decision. If it is an Apple issue then they should either fix it and or warn us of such.
Anyone else have this issue? How do you feel about it? What have you done to resolve it? Let me know in the comments below.
Windows Phone 7.8 is an update for Windows Phone 7.5 phones. New features available in Windows Phone 7.8 include new customizable start screen, new tile sizes – small, medium, large, and 20 colours for theming.
That's the good news. The bad news is that not all Windows Phone 7.5 devices will be upgraded. It all depends on your country location, your make of phone and your carrier. From the Windows Phone site "The Windows Phone 7.8 update is not available in all markets or for all phones."
Why I cannot upgrade to Windows Phone 7.8
I tried multiple times via Zune and my phone, but I continually get the message that my phone is up to date. I was sitting on 7.5 (version 7.10.8773.98).
The reason being, as far as I can tell, is not that the update is not available, but that it is only available for certain markets. This largely depends on the country and carrier and make and model of the device. In my instance this would be a Nokia Lumia 800, from Vodacom in South Africa. The issue, as far as I can tell, is that the carrier and the phone maker have to approve the upgrade for their particular device. So far neither Nokia nor Vodacom have done so for South Africa.
Apparently it will be done, but how long it will take is anyone's guess.
Searching the internet I found many suggested ways to upgrade your phone. Most are very suspect involving some dodgy hacks and resetting or wiping your phone. The best trick I found, aptly termed "The Cable Trick" worked really well for me, and also uses the normal method of Windows Phone updates through Zune.
In a nutshell, when you check for available updates through Zune, a check is done on your phone for country and carriers and make. If this passes you then get a message to say that there is an update available with a button to start the update.
The trick is to fool this process. This is done by disconnecting the internet during the update query request. Timing is essential. What this does is that it confuses the update mechanism. When it cannot confirm your country or carrier it proceeds to the update as a matter of course.
So how do you do it? Well you would normally go to Zune -> Phone -> Settings and click update on the list to the right. After a period of time, disconnect the internet cable, wait a few seconds and the update should then be available. Proceed with the update as normal.
How long do you wait before you unplug the cable? Well that's the trick. It's hit and miss situation. If you get a message in Zune that says your phone is up to date, then you have waited too long to pull the cable. If you get a message that says that it can connect to the update, then you pulled the cable out too early.
Some have suggested waiting between 6-10 seconds. But that time is really determined by many factors, prime being your bandwidth speed. For me I waited anywhere between 30 seconds and 120 seconds.
Here is what you do.
Turn off all data and Wi-Fi access on your phone
Connect as normal to you PC via USB
If Zune has not loaded, start it up
Go to Phone Settings and click update.
Wait for a few seconds, 3-120s (you will have to test this out. Try and try again until you get the timing right)
Unplug the network (internet) cable
Wait for Zune to find the update
If you get a message to say Zune can't connect. You've unplugged too early
If you get a message to say your phone is up to date, you have unplugged too late
Click the button and follow the prompts to update.
Repeat multiple times until you get to Windows Phone 7.8 (Each update will update to a newer build until you get to 7.10.8862)
Entity Framework's navigation properties maps to the relationships in the database world. In Entity Framework a navigation property on a particular entity is actually a collection of related entities. Consider the following diagram.
Here we have a product that has a relation to various other entities but in particular to SalesOrderDatail via a one-to-many relationship. We also notice that there is a section on each entity called Navigation Properties. Highlighting each navigation property will show us the navigation path. In this case the Navigation Property "SalesOrderDetails" on the Product Entity has a path from Product to SalesOrderDetail via the ProductID property of both the Product and SalesOrderDetail entities.
In Entity Framework the relationship is termed the "Association". This association represents the relationship as found in the underlying database. The association together with the navigation properties will bring back a collection of entities. In this the navigation property SalesOrderDetails of the Product Entity is a Collection of SakesOrderDatails.
We can use regular Linq to navigate through the Associations and retrieve related data. In the example below we are first retrieving a single product, and then we retrieve all the related SalesOrderDetails that are related to that particular product.
using (EFDemoEntities etx = new EFDemoEntities())
{
var prod = etx.Products.SingleOrDefault(s=> s.ProductID == 707);
var so = prod.SalesOrderDetails;
}
In fact we could do this in one line:
using (EFDemoEntities etx = new EFDemoEntities())
{
var so = etx.Products.SingleOrDefault(s=> s.ProductID == 707).SalesOrderDetails;
}
This would return a Collection of SalesOrderDetails. In fact it is a ICollection.
Obviously you could also navigate the other way round. Say you want to see what Products relate to a certain Order Detail. By using the Product Navigation property of the SalesOrderDetail Entity we would easily achieve our goal. The following would return the Product associated or related to the SalesOrderDetail with a ID of 110751.
using (EFDemoEntities etx = new EFDemoEntities())
{
var prod = etx.SalesOrderDetails.SingleOrDefault(s=> s.SalesOrderDetailID == 110751);
Anonymous types in Entity framework is a feature that enables you to create objects without declaring a class beforehand. You create the anonymous type by using the var keyword to declare your type.
Returning Anonymous Types
Entity Framework is all about classes and entities. So a simple Linq query will return a correct type as expected.
IQueryable cust = from c in context.Customers select c;
Works perfectly because we already have a Customer type class declared in our Model. However if we change the signature slightly we end up having to return an anonymous type. Say we want to only return a subset of columns. In SQL this is easy by just listing the column names. In Entity Framework we have to do this slightly differently. Remember we are coding against entities and classes. So the classes have all the columns as properties. The moment we deviate from that we end up with an anonymous type.
Let's use the same Linq query above but change it slightly to return only a few columns. We do this by using the new keyword in our select statement. The new keyword should give you a hint that this is indeed a new class.
IQueryable cust = from c in context.Customers selectnew
{
c.CustomerID,
c.FirstName,
c.LastName
};
Trying to execute this throws an exception telling us that the Anonymous type cannot be converted to the Customer type.
Cannot implicitly convert type 'System.Linq.IQueryable' to 'System.Linq.IQueryable'. An explicit conversion exists (are you missing a cast?)
What's happening here? Well it's simple, the Customer class does not have a signature where there are only three properties namely CustomerID, FirstName and LastName. Even though those properties are part of the Customer class. Within the customer class are various other properties.
In order to get this to work we have to use the var keyword to declare an anonymous type. So the following would work fine.
var cust = from c in context.Customers selectnew
{
c.CustomerID,
c.FirstName,
c.LastName
};
This would return a type of IQueryable. In normal circumstances you can bind to this type. Problem comes in when you have to return from a method of some sort. You will soon find out that you cannot return an anonymous type. By its very nature an anonymous type is local to the procedure or method. If you tried to compile the following you will get an error thrown that says: The type or namespace name 'Anonymous' could not be found.
void Main()
{
var cust = GetCustomerColumns();
}
public IQueryable GetCustomerColumns()
{
var cust = from c in context.Customers
selectnew
{
c.CustomerID,
c.FirstName,
c.LastName
};
return Cust;
}
Class Projection
One of the workarounds is to project our new anonymous type in to a new concrete type that we create. What we can do is create a new class that has only the three properties in it. Then project our Linq query to return into the new projected type.
Have a look at the following code. Here we create a new class CustomerAlt with the three needed properties. We then project the result of the Linq data into that new class.
void Main()
{
var cust = GetCustomerColumns();
}
IQueryable GetCustomerColumns()
{
var cust = from c in Customers
selectnew CustomerAlt
{
ID = c.CustomerID,
FirstName = c.FirstName,
LastName = c.LastName
};
return cust;
}
class CustomerAlt
{
publicint ID {get;set;}
publicstring FirstName {get;set;}
publicstring LastName {get;set;}
}
This then produces a cust object of type IQueryable. We can then return that concrete type effectively.
Entity Framework 5 is the latest release of Microsoft ADO.Net data access. As with all data access frameworks, the prime purpose is to access and manipulate data. Entity Framework would be useless as a data access framework if it could not do so.
In my previous post on Entity Framework and CRUD operations I go through Create, Retrieve, Update and Delete operations using Linq to Entities and Entity Framework. In this article I will show how with Entity Framework we can perform multiple CRUD operations at once, allowing Entity framework to decide what to do, how to do it, and which operation to do first.
Create, Retrieve, Update and Delete
The challenge is that you have to update a row, create a new row and also delete a row. Traditionally we think of all three of these operations independently and rightly so. But also we would update the database independently three times. But in Entity Framework we are not working against the database so there is no need to think in database terms. So with Entity Framework 5 we can perform all three operations and only call the save changes once. By doing this we leave all the database decisions to Entity Framework.
First we will find a row and then update it
//Update
Customer cust = GetCustomer(30126);
cust.LastName = "CrudSurname";
Without saving to the database, we will now delete a row
//Delete Customer
var delCustomer = GetCustomer(30136);
if (delCustomer != null)
etx.Customers.Remove(delCustomer);
Then without saving the data again, we add a new row
Now we call save changes once and Entity Framework takes care of update, deleting and adding all the data for us.
etx.SaveChanges();
Is there some magic happening here that we are not aware of? Well not really. Remember that we are not coding against a database, so do not think in database terms. Think in data model terms, in classes, entities and collections. Another important thing to remember is that the dbContext SaveChanges is wrapped in a transaction. So if one operation fails they all fail. Let's look the SQL to see how Entity Framework handles the SQL.
Baring the SQL statements that retrieve the correct rows to delete and update we can see that Entity Framework actually creates the three SQL statements for us. By doing we do not have to deal with or worry about the actual SQL that will eventually accomplish the task.
Entity Framework 5 (EF5) is the latest public release of Microsoft's ADO.net Entity Framework model. The whole purpose of Entity Framework is to make working with data easier and faster. CRUD (Create, Retrieve, Update, Delete) operations is how we add new data, delete data, update existing data and retrieve or pull data from a database.
A framework or ORM such as Entity Framework is totally useless for data operations if it no ability to perform CRUD operations.
Today we are going to look at how to perform these CRUD operations using Linq to Entities. The assumptions that we have is that you have already created your Model and you are at least familiar with Linq.
In all cases we have to have a context to programme against. So I am going to use the using (EFDemoEntities dbc = new EFDemoEntities()) method in all my examples
Retrieve Data
using (EFDemoEntities dbc = new EFDemoEntities())
{
var prodModels = from p in dbc.ProductModels
select p;
}
Above is a simple Linq statement that retrieves all data and all columns from the ProductModel table. Because we are using Linq To Entities we are programming against the Entity (Class), i.e. ProductModels. This would then return a IQueryable collection of ProductModel (IQueryable). Remember that Entity Framework uses lazy loading by default. This means that the SQL statement is prepared by no actual SQL execution is performed by the database to retrieve the data until it is actually needed. That is we have to iterate over the collection or use something else that will perform some kind of iteration, like binding to a grid.
So in the example above and all other examples, unless otherwise stated, we will automatically bind to a grid to product a similar output as below. This would then be a sample result of the above Linq statement.
To update date we retrieve a single row by using a where clause. That would return a single object. We can then alter the property values of the object and the save it back to the database.
There are several ways of retrieving a subset of data. The simplest is to use a where clause.
using (EFDemoEntities dbc = new EFDemoEntities())
{
var prodModels = (from p in dbc.ProductModels
where p.ProductModelID == 10
select p).SingleOrDefault();
prodModels.Name = "New Product Name";
dbc.SaveChanges();
}
Notice the use of the SingleOrDefault extension method. This ensures that we get a single populated ProductModel Object. Single would throw an exception if the resultant query returned more than one row. We would then make any changes we need to by changing the values of one or any of the properties.
prodModels.Name = "New Product Name";
Now to save the changes we just call the SaveChanges method of the Context
In order to create or insert new date we first instantiate a new type. We then update the values of the properties. Next we add it to the underlying set of the context and then save that back to the database.
Notice the extra select with the scope_identity() statement. This is actually returning the inserted row back to our model. In fact we can use that new inserted row and bind it directly to a control. So if you inspected newProductModel and or bind it to a control right after the save changes method, you would expect to see data if all went well.
Deleting Data
Like updating data I need to first retrieve the row that I want to delete and then delete it. This might at first seem weird, but remember we are working with objects. So our typed Entity Object needs to know which row or data it needs to delete. Once we have that we can then just delete it from the Entity set of the context. We use the Single() extension method to make sure we get only one row back. This would through an exception if either a null or more than one row is returned.
using (EFDemoEntities dbc = new EFDemoEntities())
{
ProductModel delProdModels = (from p in dbc.ProductModels
where p.ProductModelID == 129
select p).Single();
//Delete
dbc.ProductModels.Remove(delProdModels);
//Save the changes to the database
dbc.SaveChanges();
}
The following SQL would be produced, excluding the initial select to find the row:
-- Region Parameters
DECLARE@0Int= 129
-- EndRegion
delete[SalesLT].[ProductModel]
where ([ProductModelID]=@0)
Conclusion
CRUD operations are extremely important. Using Entity Framework makes that job just a little easier. The thing we have to keep in mind is that we are not programming against a database but against the Entity Model even though our final result will affect the database.
What is Entity Framework? A question that many developers have asked. Basically Entity Framework is an ORM (Object Relational Mapping) tool introduced in .NET 3.5. Entity Framework 5 (EF5) is the latest public release of Microsoft's ADO.net Entity Framework model. As of this writing, Entity Framework 6 is the next major release and is currently in Beta. You can see the Entity Framework Roadmap on CodePlex.
Entity Framework is the Microsoft preferred method of data access for .NET applications. The Entity Framework allows you to develop applications that utilize a model designed to sit between the actual data storage schema and the user interface within an ASP.NET application. Database generally store and access data in a relational way and have no concept of a data model or objects. Also, the database is not type safe, which can play havoc in a type save programming environment. As a result, Entity Framework also allows developers to program against a conceptual model that reflects application logic rather than a relational model that reflects the database structure.
Different Workflows
With Entity Framework there are different workflows, actually 3, you can follow to actually create you model.
Database First: This workflow is perfect if you already have a database or prefer using another tool to create your database. Database first takes your existing database and reverse engineers it to create the classes (entities) and mappings. This model maps all database tables, views, stored procedures and column into classes, methods and properties.
Model First: This is perfect when you do not have a database and also prefer to work in a visual environment when designing your model and database. Also, if you are not using another data modelling too. Once done, you can generate code to create the database and all its tables as well as generating the entity or classes to be used in code.
Code First: This is perfect when you are in total control of all facets of the development cycle, including developing the database. It is also perfect if you prefer to get down and dirty and don't mind writing a few lines of code. Here you manually define your classes, relationships and mappings in code and later generate a database to use.
For this article I will be using a Database First approach. For two main reasons, one; I am mostly involved with large corporations which already have a production database in place or they have dedicated database teams building the perfect database, and second, I like working in a visual environment. Less code for me the better.
Building the Database First Model
Begin by adding an Entity Framework Model to an existing project. Select ad new item then select ADO.Net Entity model from the Data Templates column.
Next select Generate from database after clicking add. Here you can also go the model first route by selecting the Empty model option.
Next choose you data connection by either using an existing connection or by creating a new connection. Creating a new connection should be familiar to you if you have ever worked with databases before.
By select a new connection you can change the connection properties as per normal using the connection properties dialog.
Once that is done you are now left with selecting the entities (tables and views) and stored procedures and Functions to using in your application. Expanding each section will allow you to select or deselect each object under Tables, Views and Stored Procedures and Functions.
Once finished a model will be generated and you will be presented with a Entity Diagram.
Querying Entity Framework Using Linq
Now that you have a model in place you can query the model and work with data using Link, or more specifically Linq to Entities. Below is what the ProductDescription class might look like based on what we have done above.
Now using a simple linq based query we can pull through the data. Notice that my code and model has no idea of the database structure. This is because I am coding against the Model, aka the DbContext.
Microsoft is stopping Windows Phone 7.8 and Windows Phone 8 support in second half of 2014. This according to a support document on Microsoft's website. Twitter is abuzz with the doom and gloom phrases spelling out the end of the world for Microsoft and Windows Phone.
But is that really the case or is it just common practice? Is it not just Microsoft keeping us informed as to what they are doing without revealing too much detail?
Remember that the end of support dates is 18 months away (from release date). Even as of today, 18 March 2013, that is still a way to go. The timelines reveal that Microsoft seems pretty committed to an 18-month support cycle for mobile software releases, but it is interesting to see this information made official before Microsoft has done much at all to indicate what comes next.
Anyway if you real Microsoft's MSL (Microsoft Support Lifecycle) document, you soon realise that this is not new. "Mainstream Support for Business and Developer products will be provided for 5 years or for 2 years after the successor product (N+1) is released, whichever is longer. Microsoft will also provide Extended Support for the 5 years following Mainstream support or for 2 years after the second successor product (N+2) is released, whichever is longer. Finally, most Business and Developer products will receive at least 10 years of online self-help support."
This does not mean that your phone is about to stop working, nor will it stop working in 18 months' time. It also does not mean that no updates will happen between now and then, It just means that Microsoft have a plan for the mobile phone operating system, namely Windows Phone.
Microsoft did make a mess of their previous upgrade path from Windows Phone 7.8 to Windows Phone 8. But it seems that they have learned their lesson because Microsoft have said that there will be an upgrade path for Windows Phone 8.
The fact that they have not announced a Windows Phone successor is neither here nor there. With Windows Phone 8 released just a few months ago, Microsoft is still early in the products life cycle. Greg Sullivan, a senior marketing manager at Microsoft said; "We're not going to do this thing where we announce the next version [of Windows Phone] months and months before it's available." He went on to say; "Over the course of the next several months, I wouldn't be surprised to see some exciting new devices and more interoperability before we start talking about what [opeating system] is next." Sullivan also said that Windows Phone 8 was flexible enough to adopt new hardware components, which was a huge problem for Windows Phone 7. "We're going to have an upgrade path going forward," he said.
The next operating system update is rumoured to be codenamed "Windows Phone Blue." So don't get your nickers in a knot. Don't jump on the Twitter doom-'n-gloom band wagon. Wait for an official word. But for all intense and purposes Microsoft seem committed to the Windows Phone Market. It just seems that they are holding their cards close to their chest.
What is the difference between IQueryable and IEnumerable? Why do we have to understand the difference between IQueryable and IEnumerable? Will it really matter?
Well it will matter, depending on what you are doing. Choosing to return IQueryable or IEnumerable when querying 1 million rows can make a big difference in performance. It could also impact on how you work with the data.
The main differences between IQueryable and IEnumerable are:
IEnumerable is best suitable for working with in-memory collection, whereas IQueryable is best suited for remote data sources, like a database or web service.
IEnumerable has immediate execution, whereas IQueryable has deferred execution or lazy loading.
So when you have to simply iterate through the in-memory collection, use IEnumerable, if you need to do any manipulation with the collection like Dataset and other data sources, use IQueryable.
Let's have a look at a practical example. First we will look at IEnumerable and then at IQueryable.
IEnumerable
The following Linq query returns a filtered set of data from a customer table in a database. For the sake of this example the Customer table has 15,000,000 rows in it.
MyDataContext ctx = new MyDataContext();
IEnumerable cust = Customers
.Where(c => c.LastName.Contains("A"));
Cust = cust.Take(10);
The result is that a Customer object of 10 items (rows) is returned. This is what we expect. However when we look at the SQL that is generated, we soon realize that this is not what we wanted.
What's wrong with this SQL statement? Well, the most obviousis, it is returning all rows in the table that contain the letter "A" in the LastName Column. If our table has 15 million rows, and a great percentage of the lastname will contain the letter "A", then it stands to reason that a few million, perhaps over 10 or even over 14 million rows will be returned. This could have serious implications for memory, performance and a bunch of other things.
But the amount of rows that were finally returned were only 10. Why? Because IEnumerable executes the first statement immediately (IEnumerable cust = Customers.Where (c => c.LastName.Contains("A"));) which pulls through millions of rows into memory. It then filters on those millions of rows (cust = cust.Take(10);) in memory resulting in 10 rows finally being returned.
IQueryable
Now let's do the exact same thing, but this time return an IQueryable. The following Linq query returns a filtered set of data from a customer table in a database. For the sake of this example the Customer table has 15,000,000 rows in it.
MyDataContext ctx = new MyDataContext();
IQueryable< Customers > cust = Customers
.Where(c => c.LastName.Contains("A"));
cust = cust.Take(10);
The result is that a Customer object of 10 items (rows) is returned. This is what we expect. When we look at the SQL that is generated, we realize that this is exactly what we expected.
DECLARE @p0 NVarChar(1000) = '%A%'
SELECT TOP (10) [t0].[CustomerID], [t0].[NameStyle],
Notice the use of the "Top (10)" in the SQL Statement. This is applying a further filter to the data. This was added because of our cust.Take(10) addition to our Linq query. What's happening here? Well because of deferred execution or lazy loading of IQueryable the SQL query is constructed at the very last moment, only when it is enumerated. So any additions to the Linq query will be part of the SQL as long as it is not enumerated. While in our IEnumerable example the SQL is constructed immediately and returned and then the Take(10) additional filter is applied when in memory.
In this example only 10 rows are returned from the SQL database. The IQueryable took 0.7 seconds. The IEnumerable looked like it returned 10 rows as well, but it took 34.7 seconds. This is clearly not what you wanted. That's a 4857% loss in performance. Never mind the memory bloating that is taking place.
IEnumerable and IQueryable Compared
IEnumerable
IQueryable
IEnumerable exists in System.Collections Namespace.
IQueryable exists in System.Linq Namespace.
IEnumerable can move forward only over a collection, it can't move backward and between the items.
IQueryable can move forward only over a collection, it can't move backward and between the items.
IEnumerable is best to query data from in-memory collections like List, Array etc.
IQueryable is best to query data from out-memory (like remote database, service) collections.
While query data from database, IEnumerable execute select query on server side, load data in-memory on client side and then filter data.
While query data from database, IQueryable execute select query on server side with all filters
IEnumerable is suitable for LINQ to Object and LINQ to XML queries.
IQueryable is suitable for LINQ to SQL queries
IEnumerable supports deferred execution.
IQueryable supports deferred execution
IEnumerable doesn't supports custom query.
IQueryable supports deferred execution
IEnumerable doesn't supports custom query
IQueryable supports custom query using CreateQuery and Execute methods
IEnumerable doesn't support lazy loading. Hence not suitable for paging like scenarios.
IQueryable support lazy loading. Hence it is suitable for paging like scenarios.
Extension methods supports by IEnumerable takes functional objects
Extension methods supports by IEnumerable takes expression objects means expression tree
Conclusion
There is a difference between IQueryable and IEnumerable. One needs to understand those differences in order to get the best performance and the best result out of our Linq queries. Both have their place and when used effectively will enhance our code and make our applications not only scream but also correct (as far as IQueryable and IEnumerable is concerned).