Update existing Data

Oct 2, 2010 at 5:58 PM

Hi,

I have a question, how can I save an existing record.
My approach is as follows:

 
public string UpdateCustomer (Database database, Customer customer)
        
(
            
var returnValue = string.Empty;
            
try
            
(
                
var query = (from customer in search database.Table <Customer> ()
                             
where searchCustomer.Id == customer.Id
                            
select search customer);
                
if (query.count () == 1)
                
(
                    
/ /? like others, I saved the customer

                
)
                
database.Table <Customer> () Save ();.
                
database.Save ();
            
)
            
catch (Exception ex)
            
(

                
returnValue = ex.Message.ToString ();
            
)
            
return return value;
        
)

For a solution, I would be very grateful

Coordinator
Oct 3, 2010 at 1:06 AM

All you do is change whatever properties you need and call Save()

 var query = (from customer in search database.Table <Customer> ()
                             
where searchCustomer.Id == customer.Id
                            
select search customer);
                
if (query.count () == 1)
                
(
                    
query.First().Name = "New Name";

                
)
                database.Save ();

Oct 3, 2010 at 10:43 AM

Hi,

ops

super Support from you

 

Thanks

 

Sebastian