We’ve found 32 gist results

netnr / ToDataTable-ToModel.cs csharp
2018-11-03 10:06
实体转表、表转实体
/// <summary>
/// 实体转表
/// </summary>
/// <typeparam name="T">泛型</typeparam>
/// <param name="list">对象</param>
/// <returns></returns>
public static DataTable ToDataTable<T>(this IList<T> list)
{
    Type elementType = typeof(T);
    var t = new DataTable();
netnr / libgdiplus-mkfontscale shell
2018-10-20 09:56
Linux安装字体,asp.net core 验证码
# 安装字体
yum -y install fontconfig
cd /usr/share/fonts
#创建新的字体文件夹
mkdir invoice_needed_font
#修改invoice_needed_font目录的权限使root用户以外的用户也可以使用
chmod -R 755 /usr/share/fonts/invoice_needed_font
#拷贝字体到invoice_needed_font文件夹

#如果提示 mkfontscale: command not found,需自行安装 #yum install mkfontscale
netnr / vsftpd shell
2018-10-20 06:22
安装 FTP
#检查是否安装(没任何反应)
chkconfig –list | grep vsftpd

#安装
yum install vsftpd

#创建日志
touch /var/log/vsftpd.log

#自启动
netnr / RequesToModel.cs csharp
2018-09-26 13:08
反射参数为实体
/// <summary>
/// 反射参数为实体
/// </summary>
/// <typeparam name="T"></typeparam>
/// <param name="model"></param>
/// <param name="request"></param>
/// <returns></returns>
public static T RequesToModel<T>(this T model, HttpRequest request = null)
{
    if (request == null)
netnr / ToDataTable csharp
2018-09-26 13:04
实体转表
/// <summary>
/// 实体转为表
/// </summary>
/// <typeparam name="T">泛型</typeparam>
/// <param name="list">对象</param>
/// <returns></returns>
public static DataTable ToDataTable<T>(this IList<T> list)
{
    Type elementType = typeof(T);
    var t = new DataTable();
netnr / OfJson.cs csharp
2018-09-26 13:03
JSON字符串转义
/// <summary>
/// 字符串 JSON转义
/// </summary>
/// <param name="s"></param>
/// <returns></returns>
public static string OfJson(this string s)
{
    StringBuilder sb = new StringBuilder();
    for (int i = 0; i < s.Length; i++)
    {
netnr / mysqldump shell
2018-09-21 15:40
mysql备份还原
#备份格式
mysqldump -u 账号 -p 数据库 > 路径

#备份库(表结构及数据)
mysqldump -u root -p netnrdb > /netnr/data/netnrdb.sql
mysqldump -uroot -p123456 netnrdb > /netnr/data/netnrdb.sql

#备份库(表结构)(加 -d 不含数据)
mysqldump -u root -p -d netnrdb > /netnr/data/netnrdb.sql
netnr / drop.sql sql
2018-09-21 14:18
SqlServer删除所有表
--删除所有表
DECLARE @sql VARCHAR(8000);
WHILE EXISTS (SELECT name FROM sysobjects WHERE type = 'U')
BEGIN
    SELECT @sql = 'DROP TABLE ' + name
    FROM sysobjects
    WHERE (type = 'U');

    PRINT (@sql);
netnr / truncate.sql sql
2018-09-21 14:16
truncate清空所有表,mysql数据库
--生成清理所有表语句;
SELECT CONCAT('truncate TABLE ', TABLE_SCHEMA, '.', TABLE_NAME, ';')
FROM INFORMATION_SCHEMA.TABLES
WHERE TABLE_SCHEMA IN ( '数据库名' );
netnr / Scaffold-DbContext shell
2018-09-21 11:37
dotnet ef core 生成实体
#公共的依赖
Install-Package Microsoft.EntityFrameworkCore.Tools
Install-Package Microsoft.VisualStudio.Web.CodeGeneration.Design

#MySQL
Install-Package Pomelo.EntityFrameworkCore.MySql
Scaffold-DbContext -Force "server=localhost;database=db;uid=root;pwd=123456;" Pomelo.EntityFrameworkCore.MySql

#SQLServer
Install-Package Microsoft.EntityFrameworkCore
ˆ