0309
0609
//cshtml
//where 使用 ||
0709
<a href="add">添加</a> 和 <a href="/add">添加</a> 的区别
//一些有用的命令
public LocalContext(DbContextOptions options) : base(options) { }
public DbSet Students_DB { get; set; }
public DbSet Courses_DB { get; set; }
“ConnectionStrings”: {
“StudentsDb”: “Data Source=DESKTOP-61L5TCQ\MSSQLSERVER2017;Initial Catalog=StudentsDb;User ID=sa;Password=123456;Connect Timeout=30;Encrypt=False;TrustServerCertificate=False;ApplicationIntent=ReadWrite;MultiSubnetFailover=False”
}
services.AddDbContext(options =>
options.UseSqlServer(Configuration.GetConnectionString(“StudentsDb”)));
services.AddAuthentication(CookieAuthenticationDefaults.AuthenticationScheme)
.AddCookie(options =>
{
options.LoginPath = new PathString("/login/");
options.AccessDeniedPath = new PathString("/login/denied");
});
app.UseAuthentication();
string username = Request.HttpContext.User.Claims.FirstOrDefault(s => s.Type == ClaimTypes.Sid).Value;
string role = Request.HttpContext.User.Claims.FirstOrDefault(s => s.Type == ClaimTypes.Role).Value;
ViewBag.Stu = _context.Students_DB.FirstOrDefault(x => x.Username == username);
_context.Students_DB.Add(stu);
_context.SaveChanges();
return RedirectToAction(nameof(MainController.Index),“Main”);
Student stu = _context.Students_DB.Find(id);
_context.Students_DB.Remove(stu);
_context.SaveChanges();
return RedirectToAction(nameof(MainController.Index), “Main”);
return RedirectToAction(nameof(DptLeaderController.CheckDptEmpAplc), “DptLeader”, new { aplcId = aplcId });
var dptaplcs = _context.Application_DB.Where(d => d.Dptment.Name == dptname)
.Where(p=>p.Emp.Position == “员工” || p.Emp.Position == “部门领导”)
//.Where(a=>a.IfSubmit == true)
.Include(d=>d.Dptment)
.Include(e=>e.Emp)
.ToList();
//