Subsonic alias query – how

aliassubsonic

I am trying to build the following query:

`new Select("GTekst = ArrGruppe.Tekst", "GLTekst = ArrGruppeLinie.Tekst")
.From(ArrGruppeLinie.Schema)
.InnerJoin(ArrGruppe.IdColumn, ArrGruppeLinie.ArrGruppeIDColumn)
.Where(ArrDeltager.Columns.Kategori).IsLessThan(20)
.And("Arrgruppe.Tekst").Like("mytext");`

It generates a flawed query because of the .And() because I have aliases attached on the two columns with the same name – the And-operator is here:

... AND (ArrGruppe.Tekst LIKE @ArrGruppe.Tekst1
)',N'@Kategori0 tinyint,@ArrGruppe.Tekst1 varchar(10)',@Kategori0=20,@ArrGruppe.Tekst1='mytext'

I haven't been able to find anything on Google which could solve this problem. How do I write the Subsonic query to generate a valid SQL parameter for ArrGruppe.Tekst ??

EDIT: Problem was solved with an update from 2.1 Final to version 2.2.

Best Answer

new Select("GTekst = ArrGruppe.Tekst", "GLTekst = ArrGruppeLinie.Tekst")
  .From(ArrGruppeLinie.Schema)
  .InnerJoin(ArrGruppe.Columns.Id, ArrGruppeLinie.Columns.ArrGruppeID)
  .Where(ArrDeltager.Columns.Kategori).IsLessThan(20)
  .And(Arrgruppe.Columns.Tekst).Like("mytext");

If not try upgrading to the latest version of SubSonic http://code.google.com/p/subsonicproject/downloads/list because you may be hitting the following issue (fixed in 2.2)

Google Issue 31 - Where Expression not formatting correctly with qualified column name