Monthly Archives: October 2012

ADO.NET provider 3.0.0 for Firebird and DDEX provider 3.0.0 for Firebird released

I’m pleased to announce version 3.0.0 of ADO.NET provider for Firebird and version 3.0.0 of DDEX provider for Firebird. ADO.NET provider 3.0.0 comes with couple of bug fixes and two major improvements.

  1. Changed transaction isolation modes
  2. New installer that updates machine.config

You can read more about the first at DNET-337. Basically now ReadCommitted and ReadUncommited are same. And using (among others) FbTransactionBehavior.RecVersion/isc_tpb_rec_version. That should better match the default behavior a lot of people is expecting.

The new MSI installer now not only installs all the necessary files, but also updates machine.config file and registers the assembly into GAC (you can select not to do it). So after full install, you don’t have to do anything. You’re just ready to go.

The rest of changes can be seen in tracker log for this version.

The DDEX provider 3.0.0 comes with new installer as well. Now when you do the install, the DDEX provider is fully registered into Visual Studio (you can select version(s) during install) and ready to go as well. No need to fiddle with registry or any other files.

Hope you’ll enjoy these improvements.

Kindle 5 Paperwhite review

It has been few days with my Kindle 5 Paperwhite. I was curious about the new frontlight. I have to say I was happy with Kindle 4 Touch, as well with previous versions. But Amazon again came with something I had to see and try. And this one seemed pretty interesting (well as with the touch few years back ;) ).

First and foremost, I like Kindles. I read a lot thanks to Kindles. And I’m not going to describe all the cons we all know and were cons with Kindle 4 Touch or even Kindle 3 Keyboard. All applies here too. I’ll describe only changes – good or bad – that I feel, as an advanced user, moving from Kindle 4 Touch.

First it’s the turn on experience. In previous one, you pushed the button on bottom and that was it. Now you have to press the button and swipe the screen. One more step. I don’t know whether there was massive number of users turning on Kindle in i.e. backpack and messing up with books, but never ever that happened to me. So I see this as a weird change.

Talking about more steps, new Kindle misses the home button previous one had. Now it’s completely, absolutely, touch only. Not sure about it. I used the button because it was there, but I was not relying on it that much. Now if you want to i.e. go from book to home screen (to do something else) you have to touch the top 1/6th (guessing) and touch home icon. Yes, it’s a more steps, but I’m not doing that that often. And actually often while also checking time on Kindle (to see whether I have time for something else, like an another book etc.), so the top bar is visible. Let’s see how it turns out.

There’s also slightly new design of the UI (nothing fancy) and new view for home screen. It’s called Cover View and basically shows book covers of your books. Though great idea, i.e. on iPhone it’s very good, it’s somehow somewhat half baked here. By default you see only 3 books (collections included) in one (top) row and the bottom row is filled with recommended books (similar selection to one you see on various places on Amazon’s site). And you cannot turn it off. Well you can. Turn on parental control and turn off the store (you can still buy books through website from computer). Half baked, in my opinion. Hope it’ll be changed with next firmware.

On the other hand, what’s pretty damn good is the feature learning your reading speed and with this knowledge showing you time to next chapter (or similar mark). Great idea.

The frontlight is good. Though as Scott Hanselman already pointed, it’s not same across the whole surface, works good in dark room. You don’t need any other light. And outside or in a room where there’s enough light, it doesn’t bother. You can leave it on.

Because Kindle is also about reading, it’s good you have now wider selection of fonts. You can use Baskerville, Caecilia, Caecilia Condensed, Futura, Helvetica and Palatino. I personally need on Kindle, probably because the screen is more like a book than a computer/tablet display, serif fonts. Caecilia is default, but compared to Baskerville and Palatino not that nice (my opinion). I tried Baskerville, but I think it’s too thin and precise for Kindle’s screen. Palatino looks best (again, for me).

The fonts are related to screen. I’m sure the new one is better, simply because it’s another generation, so there was/is probably some improvement, but I was fine with previous one too. (I don’t want to judge based even on feelings, because I’m afraid I’ll be skewed to say it’s better because of simple fact, it’s a new toy. :) )

Size is little bit smaller compared to previous one. Scott Hanselman said he has a problem comfortably holding it. I had same problem with Kindle 4 Touch, but once I find the trick to grab it, it’s not a problem. And same applies to the new one – not a problem.

Overall the system seems to be little bit faster, but I didn’t done any scientific measurements, just feel. New fonts, reading speed and frontlight are I think key new features. Maybe the first two will be available to previous Kindles with firmware update, who knows. Do I still like it? Yes. Do I regret buying? No. Any questions? Feel free to ask in comments.

Only adding data while seeding in Entity Framework

I was doing my Entity Framework course this week (contact me, if you’re interested) and at one point we were in Migrations and I was explaining the Seed method. Maybe you know, by default, there’s a sample showing handy method AddOrUpdate being available. And I got I question whether there’s some method to just “add only”. So when the record is already there, nothing will be added. Inserted new otherwise.

First i was trying to align in my brain real world usage for it. Help came from others with simple example. You’re seeding initial users for application with some default passwords, real names and something more, but somebody already changed these. So you don’t want to update these back to default values. That’s the use case for the “add only”.

While it’s not hard to write this logic directly into the seeding method, it’s good to encapsulate it. The AddOrUpdate has two overloads, one where you specify properties to use for matching and one where you don’t and default key(s) are used. I created only the explicit one (it’s easier; there’s (currently) no one-line-way to get the key(s) for entity).

public static void AddOnly<TEntity>(this IDbSet<TEntity> set, Expression<Func<TEntity, object>> identifierExpression, params TEntity[] entities) where TEntity : class
{
	var keyProperties = KeyMemberNames(identifierExpression);
	foreach (var entity in entities)
	{
		var parameter = Expression.Parameter(typeof(TEntity));
		var matchExpression = keyProperties
			.Select(key =>
				Expression.Equal(
					Expression.Property(parameter, key),
					Expression.Constant(typeof(TEntity).GetProperty(key).GetValue(entity, null))))
			.Aggregate<BinaryExpression, Expression>(null, (current, predicate) => (current == null) ? predicate : Expression.AndAlso(current, predicate));
		var match = set.SingleOrDefault(Expression.Lambda<Func<TEntity, bool>>(matchExpression, new[] { parameter }));
		if (match == null)
		{
			set.Add(entity);
		}
	}
}

static IEnumerable<string> KeyMemberNames<TEntity>(Expression<Func<TEntity, object>> keySelector)
{
	var memberExpression = keySelector.Body as MemberExpression;
	if (memberExpression != null)
	{
		return new[] { memberExpression.Member.Name };
	}
	var newExpression = keySelector.Body as NewExpression;
	if (newExpression != null)
	{
		return newExpression.Members.Select(x => x.Name);
	}

	throw new NotSupportedException();
}

You can specify the key as only one property as well as composite key.

context.People.AddOnly(
	p => new { p.FullName, p.Id },
	new Person { FullName = "Andrew Peters" },
	new Person { FullName = "Brice Lambson" },
	new Person { FullName = "Rowan Miller" }
);
context.People.AddOnly(
	p => p.FullName,
	new Person { FullName = "Andrew Peters" },
	new Person { FullName = "Brice Lambson" },
	new Person { FullName = "Rowan Miller" }
);

I promised the students in my course to create method like this and publish it here. I hope they will visit my blog. :)

Firebird Conference 2012

The Firebird Conference 2012 is again going to happen in Luxembourg during October 26-27, 2012. And I’ll be there. So if you have some questions about .NET provider for Firebird catch me.

And I’ll also have two sessions:

  1. What’s new in ADO.NET provider for Firebird
  2. Getting started with Firebird from .NET with ADO.NET provider for Firebird

And I have some interesting stuff in my bag. I think you’ll like it. Either visit my sessions or wait after it’s over. ;)

See you there.