Felice Pollano Blog

The Official Fatica Labs Blog

About the author

Author Name is someone.
E-mail me Send mail

Recent comments

Disclaimer

The opinions expressed herein are my own personal opinions and do not represent my employer's view in anyway.

© Copyright 2009

UnHaddin Inflector

Here you can find an Inflector ( a strategy to singularize, pluralize case convert and much more ) very useful in code generation. Supported languages are now English and spanish.

Be the first to rate this post

  • Currently 0/5 Stars.
  • 1
  • 2
  • 3
  • 4
  • 5

Categories: Code GEneration
Posted by Felice on Tuesday, June 16, 2009 10:37 AM
Permalink | Comments (0) | Post RSSRSS comment feed

Moving NHModeller to the Oslo May Ctp

Microsoft released the Oslo May CTP, so I'm porting NHModeller to these new bits.

Porting the conole version was easy, just some error with the "null" in the AST graph, but nothing difficult. Fortunatelly NHModeller has a suite of about 100 test that really helped to catch all the problems.

The intellipad plugin is still work in progress,but finally I have something closed to the end:

 

The refactory was big, but the new plugin is simpler in code. The good news is that now is very easy to create a custom DSL editor, with squiggles and highligting. May be I will post an How to in the near future.

Be the first to rate this post

  • Currently 0/5 Stars.
  • 1
  • 2
  • 3
  • 4
  • 5

Categories: NHModeller
Posted by Felice on Sunday, May 31, 2009 1:23 PM
Permalink | Comments (1) | Post RSSRSS comment feed

NHModeller has an official home..

http://nhmodeller.selfip.com

Be the first to rate this post

  • Currently 0/5 Stars.
  • 1
  • 2
  • 3
  • 4
  • 5

Categories: NHModeller
Posted by Felice on Monday, May 18, 2009 9:21 AM
Permalink | Comments (0) | Post RSSRSS comment feed

NHModeller - Keywords Name as Field Names

When an field name conflict with some database dialect keywords, NHibernate offer a syntax in the mapping to escape the identifier so that the mapping can behave properly: quote the identifier with the "`" sign.

Unfortunately the dialect implementer is not obliged to espose a list of keywords that needs to be escaped, so I decided to put something in the NHModeller syntax to achieve the same results.

This is the sample entity:

 

NHModel{
Entity From 
{
@Select:int
@Count:int  
Another:string(30)
} in @From
}
The sign @ forces the correct escape generation in the mapping:
 
 <?xml version='1.0' ?>
<hibernate-mapping xmlns="urn:nhibernate-mapping-2.2" assembly="MyTest" namespace="MyTest.Entities">
<class name="From" table="`From`">
<id name="Id" column="Id" access="field.camelcase-underscore">
<generator class="native" />
</id>
<property name="Select" column="`Select`" type="System.Int32" not-null="true" />
<property name="Count" column="`Count`" type="System.Int32" not-null="true" />
<property name="Another" column="Another" type="String" not-null="true" length="30" />
</class>
</hibernate-mapping>
and will issue   the correct db script ( ie MsSql2005 ):
 
 
if exists (select * from dbo.sysobjects where id = object_id(N'[From]') and OBJECTPROPERTY(id, N'IsUserTable') = 1) drop table [From];
create table [From] (
Id INT IDENTITY NOT NULL,
[Select] INT not null,
[Count] INT not null,
Another NVARCHAR(30) not null,
primary key (Id)
);
 
 

 

	

 

Be the first to rate this post

  • Currently 0/5 Stars.
  • 1
  • 2
  • 3
  • 4
  • 5

Categories: NHModeller
Posted by Felice on Friday, May 01, 2009 6:13 PM
Permalink | Comments (0) | Post RSSRSS comment feed

NHModeller - Work In Progress.

Well,

Some words about NHModeller. The basic idea is to have a central point where you define the entities of your model, that is not the Xml Mapping itself,neigther a databse schema nor the classes. The idea actually is not so different from modelling starting from the mapping files, but Xml is orrible to write, even with intellisense. NHModeller aim to make simpler writing a mapping, and generates the real one as one of the artifacts.

The project uses MGrammar as a parser generator for the DSL  and Intellipad as the preferred editor. Both these comes from the Microsoft "Oslo" Project, still CTP at present.

The version I have developed till now deal correctly with:

  • Native Keys ( implicit ) or any other simple key ( not composite )
  • Property Mapping
  • One-To-Many mappings
  • Many-To-One mappings
  • Many-To-Many Mappings
  • Lazy / Eager fetching
  • Subclass

 I will post here a screenshot of the actual present version, running a just for fun blog model:

 



When a model is created, we have to launch the code generation. This is achieved by a console application, and intellipad is just spawning the process after asking the parameters.

The UI is not so good, due to my inexperience both in WPF and intellipad :(

 



After the generation we can have a glance to the artifacts generated we have:

  • Classes files
  • Xml for NHibernate mapping
  • And, expecialli thanks to NHibernate SchemaExport class, the DDL for our preferred DB ( at least if it is NH compliant )

 

 



The DDL is the most interesting part, expecially for me that I hate dealing with DB schemas... Here below an example of a DDL created for the blog model for SQL Server and Oracle.

 

 



Well, there is some more works, even if the generator till now let a newbie to start using NHibernate in minutes. We just need to compile the files in an assembly ( remember to put "Compile as" "Embedd Resource" for the hbm files), and start using the model.

Further Step-- Let use SchemaUpdate to modify a running model, deal with Components, Composite Key, Indices, One-to-One mapping. 

Be the first to rate this post

  • Currently 0/5 Stars.
  • 1
  • 2
  • 3
  • 4
  • 5

Categories: NHModeller
Posted by Felice on Sunday, April 19, 2009 8:51 PM
Permalink | Comments (0) | Post RSSRSS comment feed

NHModeller in Intellipad

 

The first test of NHModeller in intellipad:

 



A new "Mode" that show sintax coloring and run time error checking. This allow writing the DSL a little better than using the old friend Notepad.

Be the first to rate this post

  • Currently 0/5 Stars.
  • 1
  • 2
  • 3
  • 4
  • 5

Categories: NHModeller
Posted by Felice on Wednesday, April 15, 2009 6:10 PM
Permalink | Comments (0) | Post RSSRSS comment feed

NHModeller in intellipad

I decided to stops developing a completely new GUI for NHModeller, but I would like to use Intellipad instead. Intellipad is a higly configurable editor that ships with Microsoft "Oslo" SDK ctp. So far I wrote an initial NHModeller command line version, and decided to start writing a plugin for Intellipad, or, better a "Mode". The task is not so difficult, thanks to these blogs:

Until now i found a little annoying thing: It is not possible to add a command to the MiniBuffer without directly modifying a script that in shipped with Intellipad. It would be really nice if some extension point were exposed, so that a new mode can add new commands to the minibuffer.

 

Be the first to rate this post

  • Currently 0/5 Stars.
  • 1
  • 2
  • 3
  • 4
  • 5

Categories: NHModeller
Posted by Felice on Saturday, April 11, 2009 11:41 PM
Permalink | Comments (0) | Post RSSRSS comment feed

A textual DSL for NHibernate mapping

I'm working on a little project to satisfy my idea on creating a mapping for NHibernate describing the model entities in a notepad like fashion. The application I created leverage a new SDK from microsof, at present in CTP: Microsoft Oslo SDK.

The application starts from a very simple language, and starting from this creates the clsses, the hbm's and the database script ( Database script at the moment does not work... ;)

). The application deal with collections,references, subclassing, and many-to-many relationship.

Lets have a couple of screenshot, the first one about a relation Books-Authors...

  This is the hbm (whit all the mapping in a single view ):


and this the mapping ( all the classes in a view):

 



A sample with subclassing ( a just for fun financial model )

 




Well, there is still some bugs, but the application really do what expected: a lot of boring code line autogenerated from an intuitive textual DSL.

Currently rated 3.0 by 1 people

  • Currently 3/5 Stars.
  • 1
  • 2
  • 3
  • 4
  • 5

Categories: NHModeller
Posted by Felice on Monday, February 16, 2009 10:40 AM
Permalink | Comments (10) | Post RSSRSS comment feed

WCF errore 407 passando attraverso ISA server ( o altro proxy )

Piccolo problema affrontato al volo oggi: Un client WCF non raggiunge un server quando tra i due c'è un proxy che richiede autenticazione. Le credenziali dell'utente però sono sufficienti ad autenticarsi al proxy, e l'utente ha effettuato già il login. La soluzione è ( xEsempio ) dire a .NET di usare le credenziali attive, questo si fa modificanto/aggiungendo la seguenter sezione nel machine.config:

 <system.net>

<defaultProxy enabled="true" useDefaultCredentials="true">

</defaultProxy>

</system.net>

 

Be the first to rate this post

  • Currently 0/5 Stars.
  • 1
  • 2
  • 3
  • 4
  • 5

Posted by Felice on Thursday, January 29, 2009 5:40 PM
Permalink | Comments (0) | Post RSSRSS comment feed

DSL Testuali con Microsoft OSLO: I sorgenti dell'applicazione di prova..

L'applicazione non è un granchè, almeno non è come dovrebbe essere. Il motivo è che è stata scritta imparando la tecnologia "al momento", e quindi la qualità lascia un po' a desiderare.

Servono gli ultimi chart di microsoft per poter compilare l'esempio.

 

QuasiChart.zip (2.26 mb)

Be the first to rate this post

  • Currently 0/5 Stars.
  • 1
  • 2
  • 3
  • 4
  • 5

Tags:
Posted by Felice on Thursday, January 22, 2009 1:18 AM
Permalink | Comments (2) | Post RSSRSS comment feed