Skip to main content

Posts

Showing posts with the label c#

NHibernate: Using multiple database schemas with SchemaExport

Let's say you want to use NHibernate, and have tables on multiple schemas on your database. I'm using SQL Server, and my quick solution is not supported by all the databases NH supports, but it shouldn't be hard to change. If you run the SchemaExport, you will receive an error telling you that the DB schema does not exist or you have no access to it. It makes sense since the utility does not handle multiple schemas. Well, here's a simple code snipped I've written after debugging and digging into the NH source code: private void CreateSchema() { var provider = ConnectionProviderFactory.NewConnectionProvider(NHConfigs.Properties); using (var connection = provider.GetConnection()) { using (var cmd = connection.CreateCommand()) { cmd.CommandText = "IF (SCHEMA_ID('your_schema_name') IS NULL) EXEC('CREATE SCHEMA your_schema_name')" ; cmd.ExecuteNonQuery(); } provider.CloseConnect...

FitNesse + Selenium = Acceptance Testing

Update: I don't know why I've written this post in English, the presentation is in Spanish. The virtual ALT.NET was about acceptance testing, and mainly about FitNesse. It's publicly available on http://altnet-hispano.pbworks.com/van-2010-01-16-fitnesse . Hopefully any .NET developer will be able to easily setup an Acceptance Testing environment after watching this video; I've tried to cover all the important stuff required to start using it. Special thanks to Jorge Gamba for editing the video and making the whole presentation possible. Enjoy!

Full Text Searching XMLs (Lucene.NET Version)

There was a question in a spanish DBMS list, because a guy was trying to use the SQL Server Full Text Search for indexing any object in the application. The objects were being serialized as XML objects and indexed using the FTS engine, but it started to became complex when trying to perform the query. Anyway, this post is not about SQL Server, but Lucene.NET . So, I started playing again with that and I end up with this: Download Source Code . I guess this test describes all the power of the mini-framework built over Lucene: public void MixObjects() { var obj = new Foo() .SetDescription( "hello world" ) .AddBar( "text containing the word happy" ) .AddBar( "some comments the word programming" ); var obj2 = new Bar( "some comments" ); Engine.IndexObject(obj, 5); Engine.IndexObject(obj2, 5); Engine.DumpIndexInfo(); Assert.Equal(1, Engine.LookForAll() .Where( @...

Hacking ASP.NET - Rendering Controls Alone

Sometimes we want to render just a control into the client browser using native ajax (I mean, without atlas or ajax extensions), but it's not as easy as you could think... For example, if you have to render a GridView alone, without another html information you will probably see some unknown exceptions... - 1st try The first thing I made was create an empty aspx page (with no html tags) and add a GridView, but oops!, when I runned it, asp.net throws a exception saying that all the controls need to be inside a html <form>... It has sense, so close IE and try again... - 2nd try Ok... Now I already added the <form> tag into the aspx page, opened it into the browser and everything works great. But wait!, I still haven't the ajax part written.... it's not hard to do, I just have to create a XMLHttpRequest in javascript and write the response into a <div>.. When I run the page containing the ajax script, IE throws a 'Unknown Error' exactly where i wr...