Home
Help
Register
Log in

Search

 
   Active Threads  

You are here: Home > LLBLGen Pro > LLBLGen Pro Runtime Framework> Null Predicate
 

Pages: 1
LLBLGen Pro Runtime Framework
Null Predicate
Page:1/1 

  Print all messages in this thread  
Poster Message
lbluser
User



Location:

Joined on:
18-Apr-2008 09:29:09
Posted:
14 posts
# Posted on: 09-Jun-2008 15:18:22.  
Hi
I want to add the following predicate in predicate expression.

object value = "test";

IPredicateExpression predA = new PredicateExpression();

predA.AddWithOr(new FieldCompareNullPredicate(new EntityField2("Name",new DbFunctionCall("CAST {0} as Varchar",new object[]{value})),null,false));


How to add the custom EntityField2 in predicate?

e.g.

select * from employee
where employeeName = 'xyz'
and @customParam is null

where @customParam is a parameter passed in our function

please suggest a solution for such predicate

Thanks

lbluser

ldluser  Top
daelmo
Support Team



Location:
Guatemala City
Joined on:
28-Nov-2005 23:35:24
Posted:
8048 posts
# Posted on: 10-Jun-2008 06:48:11.  
Sorry, I can't catch your situation. Could you please elaborate more?

Do you want to reuse your custom EntityField2 object in another predicate?


David Elizondo
LLBLGen'ing (articles and code snippets) | linkedin | twitter
 
Top
lbluser
User



Location:

Joined on:
18-Apr-2008 09:29:09
Posted:
14 posts
# Posted on: 10-Jun-2008 07:10:50.  
Hi

yes i want to use the custom EntityField2 object in another predicate . Actually first i create a Custom EntityField2 which contains a DateTime value. Now i want to see whether EntityField2 is null or not.

Thanks

lbluser
ldluser  Top
Walaa
Support Team



Location:

Joined on:
21-Aug-2005 16:03:48
Posted:
14464 posts
# Posted on: 10-Jun-2008 08:03:05.  
Quote:
IPredicateExpression predA = new PredicateExpression();

predA.AddWithOr(new FieldCompareNullPredicate(new EntityField2("Name",new DbFunctionCall("CAST {0} as Varchar",new object[]{value})),null,false));


And what was the outcome of the above code?


  Top
lbluser
User



Location:

Joined on:
18-Apr-2008 09:29:09
Posted:
14 posts
# Posted on: 10-Jun-2008 08:14:11.  
Hi
Please see the following example to understand what i want.

select
'@CustomParam' as MyPram ,
TeamID from
Team
where '@CustomParam' is null or '@CustomParam' = ''



First i want to add '@CustomParam' in the select.
Then i want to add a predicate on '@CustomParam' which will check whether '@CustomParam' is empty/null or not.

Thanks

lbluser
ldluser  Top
Walaa
Support Team



Location:

Joined on:
21-Aug-2005 16:03:48
Posted:
14464 posts
# Posted on: 10-Jun-2008 09:08:17.  
You should be using a dynamic list where you can define your field as such

Code:
             ResultsetFields fields = new ResultsetFields(n);
             fields.DefineField(new EntityField2("Name",.....);


And then use that define resultsetField in the null predicate.


  Top
lbluser
User



Location:

Joined on:
18-Apr-2008 09:29:09
Posted:
14 posts
# Posted on: 10-Jun-2008 11:00:14.  
Hi
I tried the method, you have mentioned in the last post. But i am getting an error

Must declare the scalar variable "@LO14a40b4a3".

Code

ResultsetFields fields = new ResultsetFields(2);
            fields.DefineField(new EntityField2("Name", new DbFunctionCall("ISNULL",new object[]{name,name})),0);
            fields[1] = TeamFields.TeamId;
            RelationPredicateBucket filter = new RelationPredicateBucket();
            filter.PredicateExpression.Add((EntityField2)fields[0] == DBNull.Value);
            using (DataAccessAdapter adapter = new DataAccessAdapter())
            {

                IDataReader reader = adapter.FetchDataReader(fields, filter, CommandBehavior.CloseConnection, 0, true);
                while (reader.Read())
                {
                    string str = reader.GetValue(0).ToString();
                }

        

The query generated by LLBLGEN
Query: SELECT ISNULL(@LO14a40b4a1, @LO14a40b4a2) AS [Name], [CBAdmin].[dbo].[Team].[TeamId] WHERE ( ( ISNULL(@LO14a40b4a3, @LO14a40b4a4) IS NULL))
    
Parameter: @LO14a40b4a1 : String. Length: 9. Precision: 0. Scale: 0. Direction: Input. Value: "test name".

Parameter: @LO14a40b4a2 : String. Length: 9. Precision: 0. Scale: 0. Direction: Input. Value: "test name".


is there any need of using DBFunction for the custom EntityField2 ?
Please suggest.

Thanks
lbluser
ldluser  Top
goose
User



Location:
Central America
Joined on:
06-Aug-2007 18:21:05
Posted:
385 posts
# Posted on: 10-Jun-2008 18:22:33.  
where is the Name field actually defined? and the from clause?

gansodesoya  Top
Pages: 1  


Powered by HnD ©2002-2007 Solutions Design
HnD uses LLBLGen Pro

Version: 2.1.12172008 Final.