0

I am using DNN7.1 and it´s DAL2 which is based on petapoco.

I want to insert and update multiple items at once to reduce network traffic and connections to my SQL Server db.

This is from my "ServiceController.cs":

    [AllowAnonymous]
    [HttpGet]
    public HttpResponseMessage InsertTagsInText(int projectId)
    {
        BBWysSimpleEditorController controller = new BBWysSimpleEditorController();
        IEnumerable<BBWysTagInTextbatchInfo> items = controller. InsertTagsInText(projectId);
        return Request.CreateResponse(HttpStatusCode.OK, items);
    }

I have insert methods for single items in components controller:

    public BBWysTagsInfo InsertTagItem(BBWysTagsInfo item)
    {
        using (IDataContext context = DataContext.Instance())
        {
            var repository = context.GetRepository<BBWysTagsInfo>();
            item.TagCreatedOnDate = DateTime.Now;
            item.TagCreatedByUserID = UserID;
            item.TagLastModifiedByUserID = UserID;
            item.TagLastModifiedOnDate = DateTime.Now;
            repository.Insert(item);
            return item;
        }
    }

    public BBWysTagsInfo UpdateTagItem(BBWysTagsInfo item)
    {
        using (IDataContext context = DataContext.Instance())
        {
            var repository = context.GetRepository<BBWysTagsInfo>();
            item.TagLastModifiedByUserID = UserID;
            item.TagLastModifiedOnDate = DateTime.Now;
            repository.Update(item);
            return item;
        }
    }

But how should the components controller for the multiple inserts/updates be?

Thanks in advance.

Asle G
  • 568
  • 7
  • 27

1 Answers1

0

As a far as I know there isn't a batch update process that is supported. Also, for the most part I'm not sure if you really need to be too worried about this, unless you are talking about very high numbers of queries etc.

I checked Charles Nurses blog and don't see any notes here either.

Mitchel Sellers
  • 62,228
  • 14
  • 110
  • 173