+1-888-365-2779
Try Now
More in this section

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

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

4 posts, 0 answered
  1. humayoo
    humayoo avatar
    89 posts
    Registered:
    25 Oct 2010
    10 Dec 2010
    Link to this post
    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
  2. Ivan Dimitrov
    Ivan Dimitrov avatar
    16072 posts
    Registered:
    25 Nov 2016
    11 Dec 2010
    Link to this post
    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.
  3. humayoo
    humayoo avatar
    89 posts
    Registered:
    25 Oct 2010
    12 Dec 2010
    Link to this post
    HI,

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

    thanks
    Humayoo
  4. Ivan Dimitrov
    Ivan Dimitrov avatar
    16072 posts
    Registered:
    25 Nov 2016
    12 Dec 2010
    Link to this post
    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.
4 posts, 0 answered