# WP **Repository Path**: wppengsmile/WP ## Basic Information - **Project Name**: WP - **Description**: No description available - **Primary Language**: Unknown - **License**: Not specified - **Default Branch**: master - **Homepage**: None - **GVP Project**: No ## Statistics - **Stars**: 0 - **Forks**: 0 - **Created**: 2020-04-20 - **Last Updated**: 2020-12-19 ## Categories & Tags **Categories**: Uncategorized **Tags**: None ## README #### 更新数据库 ``` Enable-Migrations --命令是申请开始迁移的, Add-Migration --是添加迁移:需要给它取个名字,如: Add-Migration Init Update-Database --这个是在数据库生成表的语句 ``` #### 数据类型常用注解 1. [Key] 设为主键(EF Core中不能使用) 2. [Required] 设置列不为空 3. [MaxLength(int)] 设置最大长度,只能用在string类型和byte[]数组类型 4. [NotMapped] 不将该属性映射到数据库的列 5. [Table(string name)] 想要定义的表名称 #### linq常用表达式 1. where语句 ``` p=>p.UnitPrice==100&&p.Title=”ABC” p=>p.UnitPrice==100||p.Title=”ABC” 像数据库中的LIKE ‘%c++%’,LAMBDA中用p.Title.Contains(“c++”)表示; 像数据库中的LIKE ‘c%’,LAMBDA中用p.Title.StartWith(“c”)表示; 像数据库中的LIKE ‘%c’,LAMBDA中用p.Title.EndsWith(“c”)表示; ``` 2. 排序语句 ``` 像数据库中order by 升序: 通过 “对象.OrderBy(p=>p.UnitPrice)”实现 像数据库中order by 降序: 通过 “对象.OrderByDescending(p=>p.UnitPrice)”实现 像数据库中order by UnitPrice desc,Title asc: 通过 ”对象.OrderByDescending(p=>p.UnitPrice).ThenBy(p=>p.Title)” 反过来则是: ”对象.OrderBy(p=>p.UnitPrice).ThenByDescending(p=>p.Title)” ```