Records not updated for Table without Primary Key

Posts   
 
    
Suresh
User
Posts: 6
Joined: 19-Feb-2010
# Posted on: 19-Feb-2010 15:26:17   

Hi

I am working on the LLBL gen pro 2.6 version along C# dot net 2008.

Database using is Oracle 11g.

I have the problem on updating the table without primary key.

I have table called Audit Table without any primary key. I am able to successfully insert the records , but not able to delete the records.

When I do the operation like Update/Delete it is showing result as postive, but if i check in database or refetch the database, there is no effect.

Please check on my below code --------- PredicateExpression filter = new PredicateExpression(TranAuditFields.RequestId == requestId); TranAuditCollection customers = new TranAuditCollection(); customers.GetMulti(filter);

        // Display for each customer fetched the CustomerId and the CompanyName.
        foreach (TranAuditEntity c in customers)
        {
          //  Console.WriteLine("{0} {1}", c.CustomerId, c.CompanyName);
            c.AuditText = "sample audit";
        }

       int savedREcords= customers.SaveMulti(true);

this **savedREcords **variables returns result as 3 records, but if I checked in database no effects. Even I tried with another scenerio code also..........

      TranAuditEntity transaudit = null;        

        LinqMetaData linqMetaData = new LinqMetaData();

        var data = (from treeItem in linqMetaData.TranAudit
                    where treeItem.RequestId == requestId
                    orderby treeItem.AuditText ascending
                    select treeItem).Take(1);

        if (data.Count<TranAuditEntity>() > 0)
        {               
            transaudit.IsNew = false;
            string auditText = string.Empty;
            foreach (TranAuditEntity itemTranAudit in data)
            {
                transaudit = itemTranAudit;
                auditText = itemTranAudit.AuditText;
            }
              transaudit.AuditText = "Test";
              bool executed = transaudit.Save();


        }       

executed variable return true. this also not effects on database.........

I also tried with Predicate expression in Save()method , but have not effects. It always returns as updated successfully.

Same thing works fine for table with Primary Key....................

Please suggest me,,, what I am doing wrong......

I am struggling for a week ....

Please help me to fix the issue.....

Otis avatar
Otis
LLBLGen Pro Team
Posts: 39866
Joined: 17-Aug-2003
# Posted on: 19-Feb-2010 16:01:57   

An entity needs a PK to be updated, otherwise it's not possible to identify the row to update. so to solve this, add a pk field to your table.

Frans Bouma | Lead developer LLBLGen Pro