// 枚举类
public enum QuestionType
{
Text = 0,
MultipleChoice = 1
}
// 接口
public interface IQuestion
{
string Title
{
get;
set;
}
QuestionType QType
{
get;
}
string getResult();
}
// 抽象类
public abstract class QuestionBase : IQuestion
{
public string _title;
public string Title
{
get { return _title; }
set { _title = value; }
}
public abstract QuestionType QType
{
get;
}
public string getResult()
{
return "默认答案";
}
}
// 子类1
public class TextQuestion : QuestionBase
{
public QuestionType _qType;
public override QuestionType QType
{
get { return _qType; }
}
public string getResult()
{
return "文本答案";
}
}
// 子类2
public class MultipleChoiceQuestion : QuestionBase
{
public QuestionType _qType;
public override QuestionType QType
{
get { return _qType; }
}
public string getResult()
{
return "单选答案";
}
}
第四题:扩展方法(需要与GetActiveProducts同一命名空间或者引用下面方法的命名空间)
public static class test
{
public static IQueryable
{
return query.Where(r => r.IsDeleted == "false");
}
}
第五题:SQL文:
select
T2.Name,
T1.Year,
T1.Month,
sum(T1.amount) as INCOME
from Income T1
inner join User T2
on T2.Id = T1.UserId
group by T1.UserId,T1.Year,T1.Month,sum(T1.amount)
第六题:
public List
{
List
from a in incomes
join b in users on a.UserId equals b.Id
group a by new { b.Name, a.Month, a.UserId, a.Year } into g
select new UserIncomeDto()
{
Name = g.Key.Name,
Year = g.Key.Year,
Month = g.Key.Month,
Income = g.Sum(p => p.Amount)
}).ToList();
return result;
}
第七题:
HTML:
路由设置:
routes.MapRoute(
"user",
"{controller}/{action}/{Param1}/{Param2}",
new { controller = "", action = "" },
new { }
);
第八题:
public void Require(Func
{
if (String.IsNullOrEmpty(fun(this)))
{
throw new Exception(msg);
}
}
每个程序我都测过了,大致答案如此,如果有不同意见的话请追问,还望采纳~