Driver error

Topics: Core, General
Jul 30, 2015 at 8:42 AM
Hi,

My Driver :
public class StudentPartDriver : ContentPartDriver<StudentPart>
{
    private readonly IContentManager _contentManager;
    private readonly IRepository<StudentPartRecord> _studentPartRecord;
    private readonly IRepository<CourseRecord> _courseRecord;
    public StudentPartDriver(IContentManager contentManager, IRepository<StudentPartRecord> studentPartRecord,IRepository<CourseRecord>courseRecord)
    {
        _courseRecord = courseRecord;
        _contentManager = contentManager;
        _studentPartRecord = studentPartRecord;
    }
    protected override string Prefix
    {
        get
        {
            return "Student";
        }
    }
    protected override DriverResult Editor(StudentPart part, dynamic shapeHelper)
    {
        var providersList = part.Courses.Where(x => x.Student.Id == part.Id).ToList();
        return ContentShape("Parts_Student_Edit", () =>
        {
            part.Courses = providersList;
            return shapeHelper.EditorTemplate(TemplateName: "Parts/Student", Model: part, Prefix: Prefix);
        });

    }
    protected override DriverResult Editor(StudentPart part, IUpdateModel updater, dynamic shapeHelper)
    {
        updater.TryUpdateModel(part, Prefix, null, null);
        foreach (var item in part.Courses)
        {
            _courseRecord.Create(new CourseRecord()
            {
                Student = part.Record,
                Name = item.Name
            });
        }
        return Editor(part, shapeHelper);
    }
}
Record class:
public class StudentPartRecord : ContentPartRecord
{
    public virtual string Name { get; set; }

    [CascadeAllDeleteOrphan]
    public virtual IList<CourseRecord> Courses { get; set; }
}
public class CourseRecord:ContentPartRecord
{
    public virtual int Id { get; set; }

    public virtual string Name { get; set; }
    public virtual StudentPartRecord Student { get; set; }
}
Error :
Orchard.ContentManagement.Drivers.Coordinators.ContentPartDriverCoordinator - Default - NullReferenceException thrown from IContentPartDriver by UsedEquipment.Drivers.StudentPartDriver
http://localhost:31321/OrchardLocal/Admin/Contents/Create/Student System.NullReferenceException: Object reference not set to an instance of an object.
at UsedEquipment.Drivers.StudentPartDriver.<>c__DisplayClass4.<Editor>b__2(CourseRecord x) in c:\MYProject\Orchard.Source.1.8.1\src\Orchard.Web\Modules\UsedEquipment\Drivers\StudentPartDriver.cs:line 32
at System.Linq.Enumerable.WhereListIterator1.MoveNext()
at System.Collections.Generic.List
1..ctor(IEnumerable1 collection)
at System.Linq.Enumerable.ToList[TSource](IEnumerable
1 source)
at UsedEquipment.Drivers.StudentPartDriver.Editor(StudentPart part, Object shapeHelper) in c:\MYProject\Orchard.Source.1.8.1\src\Orchard.Web\Modules\UsedEquipment\Drivers\StudentPartDriver.cs:line 32
at Orchard.ContentManagement.Drivers.ContentPartDriver1.Orchard.ContentManagement.Drivers.IContentPartDriver.BuildEditor(BuildEditorContext context) in c:\MYProject\Orchard.Source.1.8.1\src\Orchard\ContentManagement\Drivers\ContentPartDriver.cs:line 43
at Orchard.ContentManagement.Drivers.Coordinators.ContentPartDriverCoordinator.<>c__DisplayClassd.<BuildEditor>b__c(IContentPartDriver driver) in c:\MYProject\Orchard.Source.1.8.1\src\Orchard\ContentManagement\Drivers\Coordinators\ContentPartDriverCoordinator.cs:line 55
at Orchard.InvokeExtensions.Invoke[TEvents](IEnumerable
1 events, Action`1 dispatch, ILogger logger) in c:\MYProject\Orchard.Source.1.8.1\src\Orchard\InvokeExtensions.cs:line 17

Could some one please help me what the error is about?

Thanks in advance