CSLA .NET

Vibrant discussion about CSLA .NET and using the framework to build great business applications.

BusinessListBase Batch Insert or AddRange solution

rated by 0 users
Not Answered This post has 0 verified answers | 0 Replies | 1 Follower

Top 500 Contributor
35 Posts
j0552 posted on Tue, Jun 26 2012 12:09 PM

 

Hi

 

I have a BLB with  AddRange and RemoveRange methods, e.g.

 

        public void AddRange(IEnumerable<int> range)

        {

            var rlce = RaiseListChangedEvents;

            RaiseListChangedEvents = false;

 

            if (range != null)

            {

                foreach (var id in range)

                {

                    Add(id);

                }

            }

 

            RaiseListChangedEvents = rlce;

        }

 

        public void Add(int id)

        {

            if (!Contains(id))

            {

                var account = AccountCreator.GetCreator(id).Result;

                Add(account);

            }

        }

 

The method is called from an MVC controller action. The problem is the range parameter could contain a few thousand ids which makes it very slow with the current implementation. Is there a way to suppress all events, rules during the inserts. I'd want to raise a single list change event at the end of the batch.

 

Setting RaiseListChangedEvents to false in the AddRange method doesn’t seem to have any effect.

 

What are my options to improve performance?

 

Thank you

Andrew

 

Page 1 of 1 (1 items) | RSS

Copyright (c) 2006-2010 Marimer LLC. All rights reserved.
Email admin@lhotka.net for support.
Powered by Community Server (Non-Commercial Edition), by Telligent Systems