1.建立Users和UserInfos两个实体类 对应的是数据库中的表 public class User { //类名+Id(User+Id)组成的字符串在数据库表中会设置该字段是主键且是按1的增量增长 public int UserId { get; set; } public string UserName { get; set; } } UserInfos表 public class UserInfo { public int UserInfoId { get; set; } publi…
在数据库时候我设计了学生的分数为nvarchar(50),是为了在从TXT文件中读取数据插入到数据库表时候方便,但是在后期由于涉及到统计问题,比如求平均值等,需要int类型才可以,方法是:Convert(int,字段名).例如:select avg(Convert(int,M_Score)) from temp 建立视图,将视图当表示用 CREATE VIEW temp AS select StudentId, MAX(StudentScore) as M_Score from T_Studen…