TL;DR
借助 ChatGPT 给 BunnyAI 写了一个H5的启动器,可以生成兔子头像,当然也可以配置生成其他的AI图片(ps. 还有些TODO 欢迎PR)
演示:
- 生成兔子头像
使用 Dapper
时,有没有遇到过类似的错误
A parameterless default constructor or one matching signature (System.Int32 CustomerID, System.String CustomerName, System.Int32 X) is required for XXX materialization
这是由于目标类 存在含参构造函数ctorA
且 不存在 不含参的构造函数
且 ctorA
与查询结果不一致(参数个数或参数类型)
同事正常做功能迭代,已有查询多返回一个字段,改动如下
public class A{
public A(int a,
string b,
+ XXTypeEnum type
)
{
A = a;
B = b;
+ Type = type
}
}
...
var sql = @"SELECT A,
B,
+Type
FROM
...
var result = await connection.Query<A>(sql);
然后就产生了上边类似的报错
A parameterless default constructor or one matching signature (System.Int32 A, System.String C, System.SByte Type) is required for A materialization
查了一下这个异常,说明很简单 需要一个无参的构造函数 或者 一个匹配签名的构造函数
,加一个空的构造函数试了的确是可以,但是为什么如此呢,看着现有的构造函数也是匹配的,仔细看下Type参数的类型并不匹配
debug 几次,得出如下结果
int
-> enum
))对于 Dapper 对应结果 Model类, 最好是不写含参ctor,如果写了含参的ctor 也要写一个 不含参的ctor(private 也可以)
ps. 使用Mysql 数据库,系统枚举值使用了 tinyint(4)
, GetFieldType
结果为 System.SByte
,附一个 tinyint
类型对应
mysql Type | FieldType |
---|---|
tinyint(1) | System.Boolean *可以通过修改连接字符串 TreatTinyAsBoolean=false 为System.SByte |
tinyint | System.SByte |
tinyint unsigned | System.Byte |
pps. 8.0.17 中已弃用整数数据类型的显示宽度 , tinyint(1)
除外,所以最好不要用tinyint(x)
的写法 具体可看mysql 8.0.19 feature
公司要开发一个新项目,之前是 .NET Framework + Sql Server
,这次要用 .NET Core + Mysql
,没怎么接触过 mysql
,所以做数据库设计之前,结合网上的资料,以及项目的使用,总结了一下Mysql设计规范。按照规范设计了数据库,目前项目开始正常开发,没遇到因为数据库设计产生的问题,记录一下。ps.随着开发,应该还会记录下mysql与SQL server的差异。
Pascal
(避免代码中太多attribute)MySQL
的保留字,如 desc
,关键字如 index
。tmp
为前缀,并以日期为后缀bak
为前缀,并以日期为后缀首部字段名 | 说明 | 首部类型 |
---|---|---|
Set-Cookie | 开始状态管理所使用的Cookie信息 | 响应首部字段 |
Cookie | 服务器收到的Cookie信息 | 请求首部字段 |
最近在面试,很多公司都有要求使用过 Redis
,之前没有用过,既然很多公司都要求会,自然是有原因的。本文试着简单学习下 Redis
,并了解下它与 MemoryCache
有什么区别的(之前在 LPS
缓存是用的 MemoryCache
)。
看下官网的说明,
Redis is an open source (BSD licensed), in-memory data structure store, used as a database, cache and message broker. It supports data structures such as strings, hashes, lists, sets, sorted sets with range queries, bitmaps, hyperloglogs, geospatial indexes with radius queries and streams. Redis has built-in replication, Lua scripting, LRU eviction, transactions and different levels of on-disk persistence, and provides high availability via Redis Sentinel and automatic partitioning with Redis Cluster.
由于工作中涉及到 API
的开发,以及第三方的对接,Postman
总是少不了使用的,除了简单的发请求,也发现了 Postman
自带的可以用到的功能,做个记录,避免再花时间学习。
Postman makes API development faster, easier, and better
这两个SQL查询的结果相同吗?
SELECT * FROM TableA a LEFT JOIN TableB b ON b.AId =a.TableAId AND a.TableAId =1
SELECT * FROM TableA a LEFT JOIN TableB b ON b.AId =a.TableAId WHERE a.TableAId = 1
先上个官方说明
Specifies a temporary named result set, known as a common table expression (CTE). This is derived from a simple query and defined within the execution scope of a single SELECT, INSERT, UPDATE, or DELETE statement. This clause can also be used in a CREATE VIEW statement as part of its defining SELECT statement. A common table expression can include references to itself. This is referred to as a recursive common table expression.
简单理解,就是把一个查询结果临时存到指定的表达式上,这个表达式就叫公用表表达式
CTE
(Common Table Expression)。 可以简单理解为一个不会实际创建的视图。