Unique Record

Posts   
 
    
shekar
User
Posts: 327
Joined: 26-Mar-2010
# Posted on: 22-Jun-2010 15:48:22   

LLBlGen 3.0 .net 2.0 Oracle 10g

Hi, I have written a function to return true if a record exist in database.

private static bool isduplicaterecord() // check duplicate records in table { var adapteraccountnature = new DataAccessAdapter(); var accountnature = new AccountnatureEntity();

        accountnature.Description = "Test";
        accountnature.Flag = ClubCentricBISpecific.StandardFlag.recordvalidflag;
        adapteraccountnature.FetchEntityUsingUniqueConstraint(accountnature,
                                                              accountnature.ConstructFilterForUCDescriptionFlag());


        if ((accountnature.Fields.State=EntityState.Fetched) != EntityState.New)
        {
            return false; // no matching records found
        }
        return true; // matching records found
    }

Problem: This always return FALSE. What am i doing wrong ! Please HELP

psandler
User
Posts: 540
Joined: 22-Feb-2005
# Posted on: 23-Jun-2010 02:13:36   

I'm not sure I understand this line:

 if ((accountnature.Fields.State=EntityState.Fetched) != EntityState.New)

It looks like you are setting the state to fetched (single equal sign) and then comparing the result to EntityState.New? I'm not even clear on how that compiles (no IDE handy at the moment to check it).

I think it should it be something like:

if (accountnature.Fields.State != EntityState.Fetched)
daelmo avatar
daelmo
Support Team
Posts: 8245
Joined: 28-Nov-2005
# Posted on: 23-Jun-2010 03:51:46   

psandler wrote:

I think it should it be something like:

if (accountnature.Fields.State != EntityState.Fetched)

Or

if (accountnature.IsNew) ...
David Elizondo | LLBLGen Support Team
shekar
User
Posts: 327
Joined: 26-Mar-2010
# Posted on: 23-Jun-2010 06:48:55   

daelmo wrote:

psandler wrote:

I think it should it be something like:

if (accountnature.Fields.State != EntityState.Fetched)

Or

if (accountnature.IsNew) ...

Thanks It worked !