.net core小知识(持续更新)
分类: 后端
简介:如何判断DateTime变量不为空可以使用 DateTime 的默认值 DateTime.MinValue 或 DateTime.MaxValue 来进行比较 DateTime myDateTime = ;
if (myDateTime != DateTime.MinValue)
{ // DateTime 变量不为空,执行相应的操作
}
else
{ // DateTime 变量为空,执行其他操作
}
SqlSuagr对数据库的操作 1、创建数据库表 _db.DbMaintenance.CreateDatabase() 2、获取数据库表列表 _db.DbMaintenance.GetTableInfoList() 3、删除数据库表 _db.DbMaintenance.DropTable(表名) 获取配置文件中的指定字符串 // 1、读字符串
string conn = builder.Configuration.GetValue<string>("conn");
// 2、读对象
Person person = builder.Configuration.GetSection("Person").Get<Person>();
.netcore用sqlsugar实现3表联查
分类: 后端
简介: var data = await _db.Queryable<DDArShop_User_ShopCartEntity, DDAr_Shop_ShopName_TaoCanEntity, DDAr_Shop_UserEntity>((a, b,c) => new JoinQueryInfos(JoinType.Left, a.ShopNameTaoCanId == b.Id,JoinType.Left, a.TenantId == c.Id)).WhereIF(!string.IsNullOrEmpty(input.shopId), a => a.ShopId.Contains(input.shopId)).WhereIF(!string.IsNullOrEmpty(input.shopNameTaoCanId), a => a.ShopNameTaoCanId.Contains(input.shopNameTaoCanId)).Where((a, b, c) => a.DeleteMark == null && a.Type == 1) .Select((a,b,c) => new { id = a.Id, shopId = a.ShopId, shopNameTaoCanId = a.ShopNameTaoCanId, shopName = b.ShopTitle, chengYiJin = a.ChengYiJin, myPrice = a.MyPrice, type = a.Type, content = a.Content, result = a.Result, userPhone = a.UserPhone, userName = c.Nickname }).MergeTable().Select<DDArShop_ShopCartOutput>().OrderBy(sidx + " " + input.order).ToPagedListAsync(input.page, input.limit);
.netcore实现base64转png并保存到指定文件夹
分类: 后端
简介: /// <summary> /// 将传入的base64转化成png /// </summary> [HttpPost("ChangeBase64ToPng")] [AllowAnonymous] public async Task<string> ChangeBase64ToPng(DDARShopCodeKeyInput input) { string data = "a"; try { // 将Base64字符串转换为字节数组 byte[] imageBytes = Convert.FromBase64String(input.base64); string outName = YitIdHelper.NextId().ToString(); string outputPath = @"C:\Users\admin\Desktop\qrcode\type"+ input.type + "\\"+ outName + ".png"; // 创建一个MemoryStream来存储字节数组 using (MemoryStream ms = new MemoryStream(imageBytes)) { // 使用System.Drawing.Bitmap加载图像 using (Bitmap bitmap = new Bitmap(ms)) { // 将图像保存为PNG文件 bitmap.Save(outputPath, ImageFormat.Png); data = "图片已保存到:" + outputPath; } } } catch (Exception ex) { data = "转换并保存图片时出错:" + ex.Message; } return data; }