how to make crud(create,update,delete) and insert in sitefin

Posted by Community Admin on 05-Aug-2018 14:45

how to make crud(create,update,delete) and insert in sitefinity 4.0 ?

All Replies

Posted by Community Admin on 10-Dec-2010 00:00

hi,

how to make crud(create,update,delete) and insert in our own table using in sitefinity 4.0 ? in sitefinity 3.7,we can create and module with our own table and perform action(like contacts module). but how can we do in sitefinity 4.0 rc ?


thanks
Humayoo

Posted by Community Admin on 11-Dec-2010 00:00

Hi humayoo,

You can use the API to create CRUD operations. The "Contacts Module" in Sitefinity 3.x  comes with its own data persistence classes , so in Sitefinity 4.0 you have to create a custom data layer using Open Access ORM for a custom module  that inherits from ModuleBase class.

Best wishes,
Ivan Dimitrov
the Telerik team


Check out Telerik Trainer, the state of the art learning tool for Telerik products.

Posted by Community Admin on 12-Dec-2010 00:00

HI,

please provide some working example ? how to make Module using Open Access ORM  like contacts module in sitefinity 3.7 ?

thanks
Humayoo

Posted by Community Admin on 12-Dec-2010 00:00

Hi humayoo,

We will provide a sample with the official release. Creating a custom module in not something trivial. Open Access is a data layer, so you need to have methods where you persists your data using the Open Access API.

Below is a sample with CRUD data operations where OA is used

public override CustomDataType CreateObject(Guid id)
 
     var ob = new CustomDataType(this.ApplicationName, id);
     
     if (id != Guid.Empty)
     
         this.GetScope().Add(ob);
     
     return ob;
 
 
 
 public override CustomDataType GetObject(Guid id)
 
     if (id == Guid.Empty)
         throw new ArgumentException("Id cannot be Empty Guid");
 
     var ob = this.GetScope().GetItemById<Blog>(id.ToString());
     ((IDataItem)ob).Provider = this;
     return ob;
 
 
 
 
 /// <summary>
  
 public override void Delete(CustomDataType objToDelete)
 
     var scope = this.GetScope();
  
     if (scope != null)
         scope.Remove(objToDelete);
 


Best wishes,
Ivan Dimitrov
the Telerik team

Check out Telerik Trainer, the state of the art learning tool for Telerik products.

This thread is closed