Thanks burningice. That works better!
However, when I have a larger number of results to return, how can I:
However, when I have a larger number of results to return, how can I:
- Reduce the load? I've tried inserting a join in the foreach statement, but that didn't work.
-
Sort and order by SubjectLevel then SubjectName?
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;
}
}
}
}