时间:2021-07-01 10:21:17 帮助过:13人阅读
3.在Service层添加“FrameInformationService.cs”继承SqlSugarBase,给连接字符串赋值
1 public class FrameInformationService:SqlsugarBase 2 { 3 public FrameInformationService(IConfiguration _configuration) 4 { 5 this.connectionString = _configuration.GetValue<string>("ConnectionStrings:CoreFrameContext"); 6 } 7 8 9 public List<Frame_Information> GetList() 10 { 11 return DB.Queryable<Frame_Information>().ToList(); 12 } 13 }
4.控制器中调用
1 public class InfoController : ControllerBase 2 { 3 public readonly FrameInformationService _service; 4 5 public InfoController(FrameInformationService service) 6 { 7 _service = service; 8 } 9 10 [HttpGet("GetInfoList")] 11 public ApiReturnValue GetInfoList(int ImgCount, int InfoCount) 12 { 13 ApiReturnValue apiReturnValue = new ApiReturnValue(); 14 apiReturnValue.Result = _service.GetList(); 15 return apiReturnValue; 16 } 17 }
以上,仅用于学习和总结
.Net Core Api-SqlSugar的简单使用
标签:图片 连接字符串 iss class connect context ext mic shard