Archive for June, 2012

How to re-enable the Bing search engine “Narrow by Date” feature…

June 26, 2012 2 comments

Bing is a cool search engine.

When you’re a software publisher and you want to see how is your product seen and talked about on the web, Bing gives results that are more interesting than Google because the armies of little goblins working for Bing are more clever than the armies of little elves working for Google.

These Bing goblins, well educated and smart as they are, are capable of stripping out all the junk content coming from anywhere around the world, copied by infamous robots machines from outer regions, from bogus sites to bogus sites, from ghost content farm to ghost content farm. This bogus content causes some Google searches to become totally irrelevant, with the good information buried among tons of rubbish, at least for the 10 first returned pages.

So, Bing is better for some searches, but Alas! The manager goblins (the elder one with beards) at Bing have decided for no reason to remove the very useful “Narrow By Date” feature. This feature allows to … well… narrow the search by date. It’s very useful when you’re using a search engine to spot the same result regularly and are only interested by the “last” documents indexed, not the one from year 1966 say… (hmmm… I wonder whether those  goblins were active at that date…).

Google has that available, up and ready, in the lower left region of the result page, in the Tools section (although I admit it’s not shown by default). Behind the covers, this Google ‘Narrow By Date’ feature works by using the TBS query string parameter (ok, and for the non-geek readers, cool down, the following should remain in the field of all possibilities).

This is all explained here in details: How to trick Google into Giving you Realtime Search

The good news is Bing also supports this hidden TBS parameter as well! So the trick is easy: just add it manually to the query string and … tadaaaaaa:


Bing Narrow By Date Missing

After (with the TBS query string parameter added, and the return button pressed):

Bing Narrow By Date

Once the “Narrow By Date” section has appeared it will stay there as long as you continue narrowing by date.

Happy Bing-ing!

CodeFluent Entities: Multiple surfaces, multiple parts

June 20, 2012 Leave a comment

As discussed in the “What is a CodeFluent Entities model?” post, CodeFluent Entities projects contain:

  • surfaces, which are graphic views of your model,
  • XML parts, which are storage units.

By default, when creating a new project, you have a single surface named “Default” and a single model part named <DefaultNamespace>.cfp which will both contain all your entities:



In the screenshot above you can tell that I have several namespaces, let’s say I want to chunk my model up, so I have one surface per namespace in addition to my default surface. Select the Surfaces folder, and create a new one, you’ll see that a dialog pops-up letting you choose which concepts you want to import:



Here’s the result after repeating this logic for each of my namespaces, isn’t it a lot more readable?!



Yet, all entities are still stored in the same, unique, model part “AdventureWorksReloaded.cfp”, making it hard to work collaboratively (doing edits on any of my surfaces would automatically check-out the AdventureWorksReloaded part as all entities are stored in this one).

This again can be changed: select a namespace and from the property grid, switch the default part to a new part.




If I do this for all my namespaces, in the end my main part will just contain project level settings, producers and import other parts:



Organizing my CodeFluent Entities project this way, each developer can be in charge of a functional namespace and work in his scope without stepping on someone else’s shoes.

Finally, you could even go one step further by enabling the “Create One Part Per Type” option which creates one part per entity or enumeration:



Not only is this a very handy option when collaborating on the same source-controlled model, but you can also get great performances on big models as it avoids to have one big XML file containing all your project.


Hope this helps,

Carl Anderson

CodeFluent Entities: Setup update

June 19, 2012 Leave a comment

Starting a few weeks ago, old timers might have noticed that CodeFluent Entities is now shipped as a single MSI and not as a zip containing two MSIs (and a readme) anymore.


CodeFluent Entities Editions

CodeFluent Entities exists in what we call two editions which both have their own installer:

  • CodeFluent Entities Core Edition: the meta-compiler, what actually builds the stuff
  • CodeFluent Entities Modeler Edition: the graphic interface, a Visual Studio extension wrapping the meta-compiler.

The Modeler Edition includes the Core Edition: it’s a Visual Studio Extension (for VS 2008 SP1 and upper) providing a user interface to the Core Edition. This was one of the two MSIs that were shipped and it’s now the only MSI that is retrieved when downloading the product.

So even though you only have a single MSI, you can still use CodeFluent Entities without the Modeler, just using XML files and CodeFluent.Build.exe in command line, as you used to using the Core Edition.


Ok, so from now on the “Core Edition-only” installer isn’t available by default anymore, but still, my development team needs it, what can I do?

If for some reason you still need the “Core Edition-only” installation MSI, please contact our support (support ‘at’ softfluent ‘dot’ com) as they can provide you with this installer.


Carl Anderson

CodeFluent Entities: Metro Style

June 15, 2012 Leave a comment

Visual Studio 2012 RC is now available with its user interface updates and so is CodeFluent Entities Winking smile

From now on, CodeFluent Entities includes three styles by default:

  • Class Designer Style,
  • Blend Style,
  • the new Metro Style

Here’s a screenshot of this new Metro Style in Visual Studio 2012 RC:



Same style in Visual Studio 2010:



What I really like about this new Metro Style is that it uses vector icons, making your model look a lot nicer when you zoom in closely:

Close-up using the Class Designer Style:


Close-up using the Metro Style:



From the “Solution Explorer”, doing a right-click on the “Surfaces” folder and selecting “Surface Rendering Configuration”, you can select one of the other provided styles or even create your own:



Hope you like it,

Carl Anderson

Many to Many Relationships with CodeFluent Entities

June 14, 2012 Leave a comment

Yesterday, Scott Allen posted on his blog a very interesting blog post named Many to Many Relationships with EF illustrating how to setup a many to many relationship with EF Code First and then, and it’s the interesting part to us, how to use the SelectMany operator to “flatten” a sequence of book authors.

In fact, we thought it was so interesting that we decided to post a little something showing how to do it in a model-first way, using CodeFluent Entities. The result is the same, yet the way to do it is quite different.


Developing the Sample

Unlike EF Code First, CodeFluent Entities is model-first, therefore it all starts by creating a model.

Here’s our model (btw here’s a little preview of our soon-to-come vector-based & metro style theme):


Code generators (named producers in the product) will translate this platform independent model into actual code. So the SQL Server producer will translate the Book and Author entities into tables, their properties into columns, since a many to many relationship is declared between the Book and Author entities, an association table will also be created.

Another nice feature which you can see in the screenshot above is that you can add what we call “instances” to your entities which will be translated by actual lines of data. It’s a convenient way to initialize your generated database with data.

Now that we have our database and data, let’s write our method which will load all this data in a flat view.

Using CodeFluent Entities you can create actual SQL views and that’s precisely what we did:


Note: see the “Auto infer lightweight entitiy” checkbox on the upper right? Checking this will generate a dedicated .NET class mapped to your view ;) See here for more info.

We created a view named “FlatView” which selects book ids, titles and author names. Here’s what it generates:

CREATE VIEW [dbo].[vBooksFlatView]
SELECT [Books].[Id], [Authors].[Name], [Books].[Title]
    FROM [Books]
        LEFT OUTER JOIN [Authors_Books_Books_Authors] ON ([Books].[Id] = [Authors_Books_Books_Authors].[Id2])
                LEFT OUTER JOIN [Authors] ON ([Authors_Books_Books_Authors].[Id] = [Authors].[Id])

Now that we have our view, we created method which loads from this view:


Methods are once again platform independent and will be translated in regular methods by a .NET producer or into stored procedures by a persistence producer. Here’s what the SQL Server producer generates:

CREATE PROCEDURE [dbo].[Books_LoadFromFlatView]
SELECT [vBooksFlatView].[Id], [vBooksFlatView].[Name], [vBooksFlatView].[Title]
FROM [vBooksFlatView]


Now let’s run side by side EF’s dynamically generated query (on the left) and CodeFluent Entities’ static one (on the right) to compare results:


Hooray, looks good Smile


Points of Interest

Many to many relationships are easy to setup: create two properties, hold shift+click and make them point to one another, set its cardinality, and you’ve got your relation! Association tables and all related code will automatically be generated.

Initialize your generated database with data: specify instances to get test data or default data.

No dynamic code: CodeFluent Entities generates stored procedures, views and etc. No dynamic code is used to so you can easily debug and predict what’s going to happen at runtime.

Platform Independent: all this logic is outside of your code, it documents your application and provides a clear picture of what the application does and how it does it. Furthermore, you can add producers to translate this model to other technologies: want to go from C# to VB.NET? Push a button. Support Oracle Database or generate WCF Services? Add a producer.


Carl Anderson

June 13th 2012 Links: Windows 8, Visual Studio, .NET 4.5, Windows Azure

June 13, 2012 Leave a comment

Following the steps of Scott Guthrie’s link-listing series, here’s our new batch of links in our own series:


Windows 8

Delivering Windows 8 Release Preview

Microsoft announces its final pre-release of Windows 8, Internet Explorer 10, and Windows 8 apps (Hotmail, SkyDrive, Messenger, etc.).


Learn to build Metro style apps

Thinking of developing a Windows 8 Metro application? You’ll find all what you need here!


A World of Samples at your Fingertips

Microsoft Windows 8 samples


Visual Studio

Visual Studio 2012 RC available

Visual Studio 2012 RC is available!


A Design with All-Caps

Microsoft’s reasoning about their all-caps menu in Visual Studio 2012 (?!!!).


My Favorite Features: Creating Storyboards with PowerPoint

A sweat feature: use PowerPoint to create your Windows 8 Metro app storyboards!



What’s New in the .NET 4.5 Base Class Library

This article covers the big (and some of the small) improvements made to the BCL in the .NET Framework 4.5.


Meet the new Windows Azure

Scott Guthrie unveils the new Windows Azure Smile



Carl Anderson

CodeFluent Entities: ASP.NET AJAX/JSON Producer sneak peek

June 8, 2012 1 comment

In the previous post we’ve seen how to generate in a few minutes an ASP.NET AJAX/JSON web site using the brand new producer (watch-out it’s pre-release software!), well here’s a sneak peek of what gets generated Smile


The homepage generated by default lists all namespaces and their contained entities:

04 - Result


Clicking on an entity gets you to the entity page:

05 - EntityPage


On the entity page you’ll find a screenshot of the entity from which this page was generated. On the left side of the page you’ll find a list of actions available on this entity which correspond in fact to business methods provided by the entity:



The generated web site uses jQuery to contact JSON web services to retrieve the data, and jQuery UI and jqGrid to display it. By the way, you’ll notice the generated web site supports jQuery UI themes out-of-the-box:

06 - Themes



Carl Anderson

CodeFluent Entities: Generate an ASP.NET Ajax/JSON web site in 5 minutes

June 8, 2012 2 comments

A brand new ASP.NET Ajax/JSON Producer is shipped (in alpha) with the latest build available (663 and upper). As we’d love to get some feedback on what you think of it and since it’s for now undocumented pre-release software, here’s a quick guide explaining how to generate an ASP.NET Ajax/JSON web site using this shiny and new UI producer Winking smile

Warning: this producer is only available with C#, and not with VB.

In this post I’m assuming you already have CodeFluent Entities up and running (installed, activated, and SQL-DMO installed to generate and deploy SQL Server databases).

Start Visual Studio, and from the brand new “CodeFluent Entities” menu, select “Starter Wizard”:

01 - StarterWizard

This will launch Visual Studio’s “File > New > Project..” window in the section and from which we’ll select “Starter Wizard“:

02 - StarterWizardProject

Name our project “Demo.ContactManager” and click “OK” to launch the wizard.

From there, follow the steps:

  • Select the “Demo.ContactManager” model,
  • Select the “ASP.NET Ajax/JSON” architecture,
  • Select the “C#” language,
  • Keep default client project name to “Demo.ContactManager.Web”,
  • Select “SQL Server” as database,
  • Set-up your connection string
  • And finish the wizard.

This will create your entire solution (solution, projects, add and configure producers to point to those projects):

03 - CreatedSolution

Right-click on the “Demo.ContactManager.Model” project and select “Build “ to build your project:

  • Doing this will generate database scripts and deploy them on your configured database,
  • Generate the .NET classes in the Demo.ContactManager class library and add required references so you can compile right-away,
  • Generate your ASP.NET Ajax/JSON web site!

Set the “Demo.ContactManager.Web” project to be the start-up project, and hit F5 to start playing with the stuff!


Any feedback? Share it on this blog, on our forums or on our Facebook page!



Carl Anderson

CodeFluent Entities: Optimizing loading performances

In yesterday’s post “CodeFluent Entities Performance Comparison”, we saw that CodeFluent Entities performed better than ADO.NET Entity Framework and NHibernate, but a little slower than LINQ to SQL and dapper-dot-net because of extra-features it provides (gets values by column name and not by an ordinal making it easier to maintain, uses default values so developers don’t have to hassle with DbNulls).

In this post we’ll see how to lower these loading times using a few techniques.

Step #1: Removing extra features

If all you need is performance and don’t care about all those extra features provided by the tool by default: disable them! You’ll sure gain milliseconds without:

  • concurrency management (select your entity and set “Concurrency Mode” to “None” in the property grid),
  • property tracking (select your entity and set “Default Property Tracking Modes” to “None” in the property grid),
  • entity tracking (select your entity and set “Tacking Modes” to “None” in the advanced view of the property grid),
  • ensure the collection type is set to “ListCollection” or “Collection” and not “List” as you’ll waste time each time the Contains method is called.

Doing this, and without writing custom code yet, you should manage to gain a few precious milliseconds.

Step #2: Squeeze strongly typed collections

In the “CodeFluent Entities Performance Comparison” post, the code used in the test was as follows:

Stopwatch sw = new Stopwatch();

for (int ct = 0; ct < 100; ct++)
    OrderCollection orders = OrderCollection.LoadAll();
    foreach (Order o in orders)
         int i = o.OrderID;

Console.WriteLine("Elapsed milliseconds: " + sw.ElapsedMilliseconds);

From lines in the database an OrderCollection was built, but you might not even need an OrderCollection object. If so, you can use the PageData<MethodName> method which returns a IDataReader object. Which lets you do something like this:

Stopwatch sw = new Stopwatch();

for (int ct = 0; ct < 100; ct++)
    foreach (Order o in LoadOrders())
        int i = o.OrderID;

Console.WriteLine("Elapsed milliseconds: " + sw.ElapsedMilliseconds);

As you can see we replaced our OrderCollection.LoadAll() call by a call to a custom method named LoadOrders. Here’s the method:

static IEnumerable<Order> LoadOrders()
    using (IDataReader reader = OrderCollection.PageDataLoadAll(null))
        while (reader.Read())
            Order o = new Order();
            o.RaisePropertyChangedEvents = false;
            yield return o;

In the code above we’ve:

  • used CodeFluent Entities to generate the PageDataLoadAll and the ReadRecord methods which allowed us to load and map results to .NET objects,
  • yet we didn’t build and OrderCollection but returned an IEnumerable<Order>,
  • extra-tip: we disabled RaisePropertyChangedEvents before filling in our object to gain some more valuable milliseconds Winking smile

Thanks to this last tip, it allowed to gain around 140ms which is pretty good given the reasonable amount of coding (14 lines).

Step #3: Do it yourself!

The last code chunk which makes our time consumption superior than in yesterday’s handmade test using a SqlCommand and doing the mapping yourself is the generated ReadRecord method. This method provides two features:

  • it retrieves values by column name instead of using an ordinal to make the code more readable and robust (changing the column order won’t break your code),
  • it uses default values for value types so you don’t have to struggle with DbNulls.

Consequently, if all you need is performance and don’t care for those two features, just write your own ReadRecord method such as this one:

public void CustomReadRecord(IDataReader reader)
    if (reader == null)
        throw new System.ArgumentNullException("reader");

    if (!reader.IsDBNull(0)) _orderID = reader.GetInt32(0);
    if (!reader.IsDBNull(1)) _orderDate = reader.GetDateTime(1);
    if (!reader.IsDBNull(2)) _requiredDate = reader.GetDateTime(2);
    if (!reader.IsDBNull(3)) _shippedDate = reader.GetDateTime(3);
    if (!reader.IsDBNull(4)) _freight = reader.GetDecimal(4);
    if (!reader.IsDBNull(5)) _shipName = reader.GetString(5);
    if (!reader.IsDBNull(6)) _shipAddress = reader.GetString(6);
    if (!reader.IsDBNull(7)) _shipCity = reader.GetString(7);
    if (!reader.IsDBNull(8)) _shipRegion = reader.GetString(8);
    if (!reader.IsDBNull(9)) _shipPostalCode = reader.GetString(9);
    if (!reader.IsDBNull(10)) _shipCountry = reader.GetString(10);
    if (!reader.IsDBNull(11)) _customerCustomerID = reader.GetString(11);
    if (!reader.IsDBNull(12)) _employeeEmployeeID = reader.GetInt32(12);
    if (!reader.IsDBNull(13)) _shipViaShipperID = reader.GetInt32(13);

Using this CustomReadRecord instead of the standard ReadRecord, I obtained even better times than the handmade data access test (possibly because CodeFluent Entities executes stored procedures whereas I was using SqlCommand in my handmade test?).

Hope this helps,

Carl Anderson

CodeFluent Entities Performance Comparison

June 5, 2012 5 comments

We often get questions on how CodeFluent Entities performs compared to other tools as LINQ to SQL, ADO.NET Entity Framework, or NHibernate.

We compared those technologies by writing simple console applications doing the same queries on the same Northwind database and running on the same machine. Here’s in pseudo code what each console application is doing:

Start timer
Iterate 100 times
   Load all orders from database
   Loop through loaded orders
End of iteration
Stop timer
Print elapsed time (ms)

You’ll find the solution used here so you can run/edit the tests yourself:

Technologies compared are:

  • CodeFluent Entities (Build 663 available here),
  • ADO.NET Entity Framework 4.0 (edmx version 2.0),
  • LINQ to SQL (.NET 4.0),
  • NHibernate 3.3,
  • Dapper-dot-net,
  • Handmade code using a SqlCommand, SqlDataReader (named SqlClient in the table below).

Tests use:

  • Visual Studio 2010 SP1,
  • .NET 4.0 (C#),
  • SQL Server 2008,
  • the Northwind database.

Results (in ms, sorted by performance results):

Technology #1 #2 #3 #4 #5 #6 #7 #8 #9 #10
SqlClient 516 524 517 518 519 524 515 518 520 520
Dapper 609 651 626 634 608 624 606 611 606 614
LINQ to SQL 765 763 775 753 749 760 763 756 767 764
CodeFluent Entities 946 960 936 944 946 965 931 950 932 954
NHibernate 2158 2123 2122 2174 2131 2212 2176 2161 2138 2200
Entity Framework 2435 2334 2327 2291 2371 2309 2283 2374 2431 2351


  • SqlClient: 519ms
  • Dapper: 619ms
  • LINQ to SQL: 762ms
  • CodeFluent Entities: 946ms
  • NHibernate: 2151ms
  • ADO.NET Entity Framework: 2351ms

Without surprises SqlClient and Dapper performed faster as all they do is execute the query and map results to objects. Right after is LINQ to SQL losing a little time by handling relationships and so does CodeFluent Entities by handling in addition property changed events and default values (spares the developer the DbNull check for value types).

NHibernate and ADO.NET Entity Framework score last to this performance test for different reasons. NHibernate because it uses reflection to build a proxy of your classes to map database values to it. Entity Framework because we’re rebuilding a context at each iteration to ensure we’re loading all our orders from database (I tried doing a refresh on all orders but that’s even worse).

In this test we used CodeFluent Entities’ default values but in a following post we’ll see how to use CodeFluent Entities to perform as Dapper and LINQ to SQL as in particular scenarios, performance is more important than features.


Carl Anderson


Get every new post delivered to your Inbox.

Join 49 other followers