Quantcast
Channel: C1 CMS Foundation - Open Source on .NET
Viewing all articles
Browse latest Browse all 2540

New Post: Question: Adding custom selectors in datatypes to display multiple field values per line in dropdowns.

$
0
0
Thanks burningice. That works better!

However, when I have a larger number of results to return, how can I:
  1. Reduce the load? I've tried inserting a join in the foreach statement, but that didn't work.
  2. Sort and order by SubjectLevel then SubjectName?
So far I've got:
using System;
using System.Collections.Generic;
using System.Linq;
using System.Xml.Linq;
using Composite.Data;
using Composite.Data.Types;
  
namespace University.Data
{
    public static class InlineMethodFunction
    {
        public static Dictionary<string, string> GetSubjectsListDictionary()
        {
            using (DataConnection connection = new DataConnection())
            {
                Dictionary<string, string> allSubjects = new Dictionary<string, string>();
                {                   
                    foreach (Subjects Subject in connection.Get<University.Subjects>())
                    {
                        var Level = (
                            from Levels in connection.Get<University.EducationLevels>()
                            where Levels.Id == (Guid)Subject.SubjectLevel
                            select Levels.EducationLevel ).FirstOrDefault();
                        allSubjects.Add(Subject.Id.ToString(), Level + " - " + Subject.SubjectName);
                    }
                }
                return allSubjects;
            }
        }
    }
}

Viewing all articles
Browse latest Browse all 2540

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>