<%服务器方法;%> (调用服务器方法,要写;)
<=%服务器方法%> (有返回值输出,不能写;)
public ActionResult Index(int id = 0) {
return View((object)new[] { "Apple", "Orange", "Peach" }[id > 2 ? 0 : id]);
}
C#知识点提要(>=3.0)
Razor语法
ASP.NET 页面之间传值的几种方式
combox系统颜色和刷子的下拉条
session和cache的区别
Func和Action委托的区别和简单使用 c#正则表达式使用小结
C# 可以使用TimeSpan计算两个时间差
private string DateDiff(DateTime DateTime1, DateTime DateTime2)
{string dateDiff = null;
TimeSpan ts = DateTime1.Subtract(DateTime2).Duration();
dateDiff = ts.Days.ToString()+"天"+ ts.Hours.ToString()+"小时"+ ts.Minutes.ToString()+"分钟"+ ts.Seconds.ToString()+"秒";
return dateDiff;
}
结构和类的区别:
1.结构是一种值数据类型,而类是一种引用类型
2.在结构中不允许定义无参数的构造函数(编译不会通过)
3.在结构中可以给结构的静态变量赋初值,但不能给结构的一个实例变量赋初值
4.创建结构对象可以不使用new关键字,直接用结构类型的变量来创建
5.不允许继承(可以将结构看成是密封的类)
http://www.cnblogs.com/CareySon/archive/2011/12/12/2284740.html
T-SQL查询进阶--详解公用表表达式(CTE),公用表表达式(Common Table Expression)
代码 Code highlighting produced by Actipro CodeHighlighter (freeware)http://www.CodeHighlighter.com/-->WITH SimpleRecursive ( Employee_NM, Employee_ID, ReportsTo ,Sublevel)
AS ( SELECT Employee_NM ,
Employee_ID ,
ReportsTo,
FROM Employee_Tree
WHERE Employee_ID =
UNION ALL
SELECT p.Employee_NM ,
p.Employee_ID ,
p.ReportsTo,
Sublevel +
FROM Employee_Tree p
INNER JOIN SimpleRecursive A ON A.Employee_ID = p.ReportsTo
)
SELECT sr.Employee_ID AS empid ,
sr.Employee_NM AS Emp ,
et.Employee_NM AS Boss
FROM SimpleRecursive sr
INNER JOIN Employee_Tree et ON sr.ReportsTo = et.Employee_ID
WHERE Sublevel <=
SqlServer 2005 CTE
with cte (deptid,dptname,parentid) as (
--起始条件
select a.deptid,a.dptname,a.parentid from base_dept a where a.deptid = 2
union all
--CTE每次递归条件
select a.deptid,a.dptname,a.parentid from base_dept a, cte where a.parentid = cte.deptid
)
--DTE必须紧跟着SQL语句使用。
select deptid,dptname,parentid from cte order by dptname;
附送一个使用CTE的例子:
--CTE
with cte (deptid,dptname,parentid) as (
select a.deptid,a.dptname,a.parentid from base_dept a where a.deptid = 2
union all
select a.deptid,a.dptname,a.parentid from base_dept a, cte where a.parentid = cte.deptid
)
select a.cdeptid,a.cdeptparentid,count(a.cid) as ccount
from base_excute_compel a,cte
where a.CompelTime >= '2010-01-01'
and a.CompelTime <= '2013-01-01'
and a.cdeptid in (cte.deptid)
group by a.cdeptid,a.cdeptparentid