Clever-1945
12/1/2017 - 5:14 AM

criteria sql #NHibernate

criteria sql #NHibernate

query = @"not exists( select * from (select cp.Contractor , ccp.Contact , PhoneString from 
                ( select pp.id as Id , dbo.getCorrectPhone(pp.PhoneString) as PhoneString  from [{ELMA_DATA_BASE}].[dbo].Phone pp ) p 
                left join [{ELMA_DATA_BASE}].[dbo].Contractor_Phone cp on ( cp.Phone = p.Id )
                left join [{ELMA_DATA_BASE}].[dbo].Contact_Phone ccp on ( ccp.Phone = p.Id )
                where cp.Contractor is not null or ccp.Contact is not null)  as tt where tt.PhoneString = (CASE WHEN this_1_.DirectionMessage = 1 THEN " + " this_1_.\"From\" ELSE this_1_.\"To\" END ))";
                    query = query.Replace("{ELMA_DATA_BASE}", elmaBase);
                    criteria.Add(Expression.Sql(new SqlString(query)));
                    
                    
----------------------------------------------------------------------------------------


var rqPrimaryCauseAction = Expression.Sql(new SqlString("ltrim(rtrim(lower(tbp1_.PrimaryCauseAction))) not like '%' + REPLACE(ltrim(rtrim(lower(this_.Insight))),  ' ' , '%') + '%'"));