Monthly Archives: November 2010

Is Firebird really free?

If you’re expecting some sensation, I’ll not make you happy. Shortly, yes, Firebird is free, completely. You can use it wherever you want and you don’t have to pay anything nor release sources of your application nor …

On the other hand, the whole truth, considering all the edge cases and consequences, is different. To keep high quality of final product, keep adding new features, provide bug fixes – simply moving forward – the creator needs some resources. If these resources will not be available, it will be effectively dead. The resources I’m here talking about, in case of Firebird, are people doing full time or regular development. These people have families, houses, hobbies, … And for all of these items you need money (in our society :) ). They’re not doing it for fun (only), but also for living as well.

So Firebird actually needs some money to keep moving. It doesn’t have licenses to buy or something like that. We’re simply relying on the fact, that people using it, similar to people working on it, do love it. And are educated enough to realize all this and provide, even small, support. Thus next time you’ll be deploying your application with Firebird, think about sending $10 or even $1. I bet it’s nothing for you (compared to price of the application or money you’re paying for toilet paper in your office). And ten thousand people (not much) donating $10 makes a huge difference. It’s not only about few donating $10000.

And by the way, Firebird is not “just” engine, but tools around too: .NET driver ;) , Java driver, documentation, QA, …, you name it.

ADO.NET provider 2.6.0 for Firebird released

Firebird .NET provider team is proud to announce next version of ADO.NET provider for Firebird – 2.6.0.

This version contains various bug fixes as well as new features and improvements. And of course support for some of new Firebird server features. Highlights:

  • .NET 4 Client Profile support
  • Entity Framework 4 support
  • Command cancellation support
  • Support for UTF8 filenames

All changes can be found at tracker.firebirdsql.org.

You can download it at http://sourceforge.net/projects/firebird/files/firebird-net-provider/2.6.0/ or http://www.firebirdsql.org/index.php?op=files&id=netprovider.

Thanks to all who helped improving and hunting issues.

FBCon 10 – “live” feed

The conference is starting today. I’ll write here during the days about what’s going on. Also check Twitter with hashtag #FBCon10 for most recent quick messages.

Day 1:
Well, I was not so active posting new content during the day, mainly because I had no connection, so I was only tweeting. Right now we’re slowly approaching the end of first day. All the sessions we’re interesting so far.

Vlad’s about new features in SQL was a good summary of all the pieces of information you collect throughout the year. The next session from Holger about character set was good as well. Though as person from .NET world my databases are alway UTF8, so I don’t care too much. But I understand, that understanding how Firebird works with different characters set is crucial to know, and not only for migrating i.e. legacy database to UTF8 or something like that. Than was my session. Most interesting, of course. ;) Well, not a lot of .NET people, only 4 attended. :) Frank’s session (actually two) about trees in database was a great, if you’re not familiar about some basic concepts of storing trees and querying these. Especially if you are (were) not familiar with recursive CTEs (which I’m using a lot).

Right now the last session of day, Holger’s about UDFs and 32bit & 64bit and Lazarus and FreePascal, is slowly starting. As I’m not using UDFs, because I’m relying strongly on built-in functions (and you can’t, right now, write these in managed code ;) ), I’ll just check what are the challenges and problems today with it.

Day 2:
Connection is today little bit better, so I can post something. We’re now in the middle (slowly approaching) of the second day. So far I’ve seen the Vlad’s presentation about ODS improvements in Firebird 3. Although it’s probably not going affect my databases so much, it’s nice to hear somebody explaining the internals as it brings you more complete view on the topic. Then we have seen some nice features of IBExpert tools from Holger. Some are really advanced. And right now I’m sitting on session about Firebird performance comparison and it’s a nice summary of different stuff you can buy and/or do to make (or not) make your database(s) running faster. In the other room Roman is doing session, but as there was some swapping, I don’t know the name :) .

Dammit. My session is now done, but my computer froze while switching virtual machines. :-\ At that time I really appreciated my effort to keep my system clean and of course my SSD. In under two minutes I was back. At least there was lot more people visiting my session compared to yesterday.

We’re slowly approaching the end of the end of the day 2, only one session comparing Firebird 2.5 architectures is left. Because I’m using 2.5 version for more than a year, I’m confident I know all the important differences. ;) Again, I’m looking to the after-dinner talks, because you’ll learn a lot of stuff (not only Firebird or databases related).

Day 3:
The final day, day 3, is now over. That means also the conference is over. Surprisingly this day was most interesting (related to session topics) for me. This first session was about the Firebird future features from Dmitry (presented by Vlad). Then Thomas’ about audit and trace. The trace is in fact, from using it perspective simple, but a lot of people might not know about it. Roman has a similar session about RIA and Java+Firebird (mine was OData+Firebird), so I was able to see how it’s done in Java world. The IBEBlock language session, well I was surprised how much functions you have available there, some of these really advanced and you can still use it as DLL and scripting. My, already mentioned, OData+Firebird session was, as I was kind of expecting after previous days, based at least on the peoples elaboration at the Q&A, interesting for them as well (and everything was working smoothly ;) ). And that’s pretty much it, last day of conference.

This year, IBExpert team did again great job with organization. Not only conference, but also all the stuff around it (except the internet connection, which was really bad). As a speaker I was in particular pleased with the recording of session. No software hassle, just some frictionless hardware box recording directly from VGA between notebook and projector.

During evening events we did some Mercedes Benz cars driving, as the conference was in their customer center and of course exchanged a lot words about Firebird, topics realted to Firebird, but also absolutely unrelated topics. Not a lot of .NET people, only few, but the others were little bit interested about the .NET world.

The next one is already planned for the beginning of 2012 (of course if somebody will not do one sooner). Looking forward to it already.

FBCon 2010 Bremen – topics on Firebird & .NET

I almost forgot to announce the topics touching ADO.NET provider for Firebird. This year I have three sessions. You can find more info, and register, of course, at firebird-conference.com. Here’s the list.

  • New features in .NET provider for Firebird
  • Connecting to Firebird using .NET provider from various devices – iPad, iPhone, Android, Windows Phone,…
  • Creating services for rich internet applications using Firebird and the OData protocol

So if you’re interested in any of these topic, come, ask, participate. Especially hearing scenarios in what you’re using the .NET provider is very valuable for me. I also like talking between sessions, I always learn something new and I’m eager to to my best to answer all questions people are asking.

Mapping private or protected properties with Code First (EFv4, CTP4)

If you’re specifying mapping in Code First in Entity Framework you’re essentially describing it with like this (assuming using EntityConfiguration class).

this.Something(x => x.Foo).Bar();

This is nice, but if the property you wanna to use is either private or protected you are hitting wall as you can’t write such expression. I faced the same problem today. The easiest approach is to have the configuration class nested to entity itself. But that’s not a clean (or may not be doable) and I do want clean code.

Because I know, Entity Framework can use these properties – if you’re using designer it’s just setting some fields in Properties window. So I concluded, that the only problem is to how to push it into Code First. My focus was primarily for MapSingleType method (but it’s doable for i.e. Property method as well).

With the method you can write two types of mapping, one using EntityMap class directly.

this.MapSingleType(x =>
	EntityMap.Row(
		EntityMap.Column(x.Foo, "FooColumn"),
		EntityMap.Column(x.Bar, "BarColumn")))
.ToTable(new StoreTableName("Baz", "dbo"));

Or one using anonymous type.

this.MapSingleType(x => new                                                       
    {                                                                         
        FooColumn = x.Foo,                                                           
        BarColumn = x.Bar                                             
    })                                                                        
.ToTable(new StoreTableName("Baz", "dbo"));                                 

With the starting point set I decided the easiest way to specify private or protected properties will be using string. The only task is to create the Expression that’s else generated by compiler. After some juggling with the trees I created this extension method.

public struct ColumnPropertyMapping
{
	public string Column { get; set; }
	public string Property { get; set; }

	public ColumnPropertyMapping(string column, string property)
		: this()
	{
		this.Column = column;
		this.Property = property;
	}
}
public static EntityMap MapSingleType<TEntity>(this EntityConfiguration<TEntity> configuration, Expression<Func<TEntity, object>> initialMapping, params ColumnPropertyMapping[] additionalMappings)
	where TEntity : class
{
	if (additionalMappings == null)
		throw new ArgumentNullException("additionalMappings");

	List<Expression> newParameters = new List<Expression>();
	var entity = initialMapping.Parameters[0];

	Func<ColumnPropertyMapping, MethodCallExpression> makeColumnCall =
		m =>
			Expression.Call(
				typeof(EntityMap),
				"Column",
				null,
				Expression.Convert(
					Expression.MakeMemberAccess(entity, typeof(TEntity).GetMember(m.Property, BindingFlags.Instance | BindingFlags.Public | BindingFlags.NonPublic).First()),
					typeof(object)),
				Expression.Constant(m.Column));

	var callExpression = (initialMapping.Body as MethodCallExpression);
	var newExpression = (initialMapping.Body as NewExpression);
	if (callExpression != null)
	{
		newParameters.AddRange((callExpression.Arguments[0] as NewArrayExpression).Expressions);
	}
	else if (newExpression != null)
	{
		newParameters.AddRange(newExpression.Arguments.Select((e, i) => new ColumnPropertyMapping(newExpression.Members[i].Name, (e as MemberExpression).Member.Name)).Select(x => makeColumnCall(x)));
	}
	else
	{
		throw new ArgumentException("initialMapping");
	}

	newParameters.AddRange(additionalMappings.Select(x => makeColumnCall(x)));

	var finalMapping = Expression.Lambda<Func<TEntity, object>>(
		Expression.Call(
			typeof(EntityMap),
			"Row",
			null,
			Expression.NewArrayInit(
				typeof(EntityMapColumn),
				newParameters)),
		entity);

	return configuration.MapSingleType(finalMapping);
}

It’s method with similar signature as the original one, but taking extra collection of ColumnPropertyMapping, my helper objects to represent the mapping as strings. I take the input – EntityMap or anonymous object – peck up the important pieces and recreate the expression with added properties. I’m resulting to tree with EntityMap, as it looked easier to create. So now you can create the mapping also for non-public properties (and also dynamic mapping is easier).

this.MapSingleType(x =>
	EntityMap.Row(
		EntityMap.Column(x.Foo, "FooColumn"),
		EntityMap.Column(x.Bar, "BarColumn")),
	new ColumnPropertyMapping("SomeColumn", "ImNotPublic"))
.ToTable(new StoreTableName("Baz", "dbo"));

// or

this.MapSingleType(x => new                                                       
		{                                                                         
			FooColumn = x.Foo,                                                           
			BarColumn = x.Bar                                             
		},
		new ColumnPropertyMapping("SomeColumn", "ImNotPublic"))                                                                        
.ToTable(new StoreTableName("Baz", "dbo"));                                 

Enjoy, if you need it. :) I hope the CTP5 will address this “scenario”, thus I’ll not be forced to write it for other methods. And if not, stay tuned, I’ll definitely post it. 8-)

Connecting from Android to Firebird

Remember the challenge I did some time ago with .NET provider for Firebird and MonoTouch? Well because I’ve got access to previews of MonoDroid, why not to try the same here?

Again it’s a pretty challenge for the whole MonoDroid stack, as the provider uses a lot of various pieces from .NET Framework. And taking into account, the MonoDroid is still in previews phase I wasn’t sure I’ll be able to succeed. However I did. With some tweaking, and I kind of remembered the important places from last attempt, so it was faster, I was able to make it work easily.


Application connected to Firebird server and showing server version and data from MON$DABATASE

Cool, isn’t it? Taking into account, that the Windows Phone 7 (because everything there is based on Silverlight) doesn’t contain pieces from ADO.NET, it’s nice that Mono isn’t crippling the objects available.

Still using i.e. OData is probably better idea, but who knows what somebody might wanna create.