-3

我不确定为什么会有错误,如果有人能对我说清楚,那就太好了。

public List<ElementModelForCourseIndex> GetElementModelsForCourseIndex(int elementId, int userId, int depthLevel = 2)
    {
        List<ElementModelForCourseIndex> TypesName;
        ElementType type = new ElementType();
        using (var db = DataContextManager.AleStoredProcsContext)
        {

            TypesName = db.GetElementModelsForCourseIndex<ElementModelForCourseIndex>(elementId, userId, r => new ElementModelForCourseIndex{
                    Id = ElementsModelsForCourseIndexMap.Id(r),
                    Identity = ElementsModelsForCourseIndexMap.Identity(r)
                }).OrderBy(n=>n.Identity).ToList();
        }
        foreach (ElementModelForCourseIndex typeContent in TypesName)
        {
            typeContent.Children = GetElementChildrenModelsForCourseIndex(elementId, userId, type.ModelId, depthLevel);
        }
    }

    public List<ElementModelForCourseIndex> GetElementChildrenModelsForCourseIndex(int elementId, int userId, ElementType typeId, int depthLevel = 2)
    {
        using (var db = DataContextManager.AleStoredProcsContext)
        {
            return db.GetElementWithCalendarAndPermsByModel<ElementModelForCourseIndex>(elementId, userId, typeId.Id, r => new ElementModelForCourseIndex
            {
                IdentityName = ElementsModelsForCourseIndexMap.IdentityName(r),
                ValueString = ElementsModelsForCourseIndexMap.ValueString(r),
                TimeReleased = ElementsModelsForCourseIndexMap.TimeReleased(r),
                TimeDue = ElementsModelsForCourseIndexMap.TimeReleased(r)
            }).OrderBy(i => i.IdentityName).ToList();
        }
    }

错误出现在需要返回语句的这一行的顶部方法中。

4

2 回答 2

1

它应该是

typeContent.Children = GetElementChildrenModelsForCourseIndex(elementId, 
                       userId, type, depthLevel);

第三个参数是罪魁祸首。它需要ElementType并且您正在提供type.ModelId(我猜是整数)

于 2013-05-06T01:59:10.207 回答
1

看起来你需要传入type而不是type.ModelId-type是一个ElementType.

于 2013-05-06T02:01:09.450 回答