Here I will post problems I and my colleagues met and solutions we found.

Monday, January 12, 2009

Lazy loading for CSLA lists to support Server mode in DevExpress Grid. Part 4

The last parts are processing DataFetch based on LazyLoadingCriteriaBase class, which is defined as:



/// <summary>
///
/// </summary>
public enum LoadingCommand
{
/// <summary>
///
/// </summary>
DoNothing,
/// <summary>
///
/// </summary>
FetchData,
/// <summary>
///
/// </summary>
LoadIds,
/// <summary>
///
/// </summary>
ChangeSorting
};

/// <summary>
/// Used to control fetching for lazy loading
/// </summary>
[Serializable]
public class LazyLoadingCriteriaBase
{
private LoadingCommand _command;
private List<object> _idList;
private ListSortDescriptionCollection _sortInfo;

/// <summary>
/// Constructor
/// </summary>
/// <param name="command"></param>
public LazyLoadingCriteriaBase(LoadingCommand command)
{
_command = command;
}

/// <summary>
/// Only ids should be fetched
/// </summary>
public LoadingCommand Command
{
get { return _command; }
}
/// <summary>
/// Only objects with ids from the list should be loaded
/// </summary>
public List<object> IdList
{
get
{
return _idList;
}
set
{
_idList = value;
}
}
/// <summary>
/// Apply sorting when loading
/// </summary>
public ListSortDescriptionCollection SortInfo
{
get
{
return _sortInfo;
}
set
{
_sortInfo = value;
}
}
}


I believe you got the idea at this point and will not put that example. Generally, at the moment you would need to modify you SQL statements to process sorting and filter items with required primary keys.

The last step is mapping our interface to IListServer, but that's again, just trivial mapper.

One more thing. You may notice some hints of multi-threading, like locking controller, flags, etc. That part was not completed, just ignore it.

1 comment:

Anonymous said...

Maxal,
This is LDSK from the CSLA forum. Thanks for sending me the link. I will have to take a look at it.