Decode/Case

Posts   
 
    
nefise
User
Posts: 22
Joined: 01-Dec-2006
# Posted on: 30-Jun-2008 15:38:04   

LLBLGEN PRO 2.5 Oracle 10g/ sqlServer2000 Innodb C#.Net 2005 Adapter

Does llblgen support Decode/Case? If it does, what is the syntax?

Walaa avatar
Walaa
Support Team
Posts: 14951
Joined: 21-Aug-2005
# Posted on: 30-Jun-2008 17:41:49   

These are DB functions, right?

Please check the following documentation section:

Generated code - Calling a database function

nefise
User
Posts: 22
Joined: 01-Dec-2006
# Posted on: 01-Jul-2008 13:55:57   

Thanks for it, it will work if I could generate a dynamic CASE statement for it.

I need to get the Database Table Names of entities, and database column names of Entities' fields. For Example;

I want to generate a Sql like this; CASE [Confida40].[dbo].[SIPARIS_KALEMI].[SATIR_TIPI] WHEN 'M' THEN [Confida40].[dbo].[ITEM].[TANIM] WHEN 'H' THEN [Confida40].[dbo].[SP_HIZMET_KARTI].[TANIMI] END AS [UHTanimi],

but i get the Sql

CASE [Confida40].[dbo].[SIPARIS_KALEMI].[SATIR_TIPI] WHEN 'M' THEN [Tanim] WHEN 'H' THEN [Tanimi] END AS [UHTanimi],

with this code

fields.DefineField(new EntityField2("UHTanimi", 
            new DbFunctionCall(
        "CASE {0} WHEN 'M' THEN [" + ItemFields.Tanim.Name + "] WHEN 'H' THEN  [" 
        + SpHizmetKartiFields.Tanimi.Name + "] END",
         new object[] { SiparisKalemiFields.SatirTipi })), 24);
Walaa avatar
Walaa
Support Team
Posts: 14951
Joined: 21-Aug-2005
# Posted on: 01-Jul-2008 16:38:14   

Please try the following:

fields.DefineField(new EntityField2("UHTanimi", 
                new DbFunctionCall(
            "CASE {0} WHEN 'M' THEN [{1}] WHEN 'H' THEN [{2}] END",
             new object[] { SiparisKalemiFields.SatirTipi, ItemFields.Tanim, SpHizmetKartiFields.Tanimi })), 24); 
nefise
User
Posts: 22
Joined: 01-Dec-2006
# Posted on: 01-Jul-2008 17:23:53   

Thanks, it works.