override方法具有无效参数

时间:2013-05-06 01:57:08

标签: c# asp.net-mvc

我不确定为什么有人能说清楚这会很好的错误。

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();
        }
    }

错误在顶行方法中,此行需要返回一个语句。

2 个答案:

答案 0 :(得分:1)

应该是

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

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

答案 1 :(得分:1)

您似乎需要传递type而不是type.ModelId - typeElementType