示例#1
0
        // TODO: add support for user-friendly ordering ([IDNameObjectMethodAttribute(Name="Order")])
        // multiselect list from in-memory collection
        public static MultiSelectList ToMultiSelectList <TEntity>(this ICollection <TEntity> selectedList, Func <TEntity, object> customOrderBySelectorFunc = null)
            where TEntity : class
        {
            var orderedList = ((customOrderBySelectorFunc == null) ? selectedList.DefaultOrder() : selectedList.OrderBy(customOrderBySelectorFunc)).ToList();
            var ids         = orderedList.ToIDList();

            return(MultiSelectListManager <TEntity> .FromList(orderedList, ids));
        }
示例#2
0
        // selectedOnly == true - list of selected items only (selectedIDlist)
        // otherwise - list of all items from the set
        public static async Task <MultiSelectList> ToMultiSelectListAsync <TEntity>(this IQueryable <TEntity> set, IList selectedIDlist, bool selectedOnly, Expression <Func <TEntity, object> > customOrderBySelector = null)
            where TEntity : class
        {
            IList ids = (selectedOnly) ? selectedIDlist : null;

            if (IDNameObjectType <TEntity> .IsSimplifiable)
            {
                var list = await MultiSelectListManager <TEntity> .SimpleINOQuery(set, ids, customOrderBySelector).ToEntityListAsync();

                return(MultiSelectListManager <SimpleIDNameObject> .FromList(list, selectedIDlist));
            }
            else
            {
                var list = await MultiSelectListManager <TEntity> .Query(set, ids, customOrderBySelector).ToEntityListAsync();

                return(MultiSelectListManager <TEntity> .FromList(list, selectedIDlist));
            }
        }