- 博客(24)
- 资源 (7)
- 收藏
- 关注
原创 MongoDB 内存占用很高
storage: dbPath: /var/lib/mongodb journal: enabled: true# engine:# mmapv1: wiredTiger: engineConfig: cacheSizeGB: 1.5配置文件默认位置 C:\Program Files\MongoDB\Server\4.2\bin mongod.cfg原因:cacheSizeGB如果不设置为本机的60%内存,但是经常一直都会占着...
2021-08-18 15:14:52
394
原创 C# 如何获取端口是否被占用
public bool PortIsUse(int port) { bool inUse = false; IPGlobalProperties ipProperties = IPGlobalProperties.GetIPGlobalProperties(); IPEndPoint[] ipEndPoints = ipProperties.GetActiveTcpListeners();//IP端口...
2021-02-18 14:41:29
2685
原创 C# 如何获取本机的IP地址
public string GetLocalIP() { IPHostEntry ipe = Dns.GetHostEntry(Dns.GetHostName()); IPAddress[] ip = ipe.AddressList; for (int i = 0; i < ip.Length; i++) { if (ip[i].Addres...
2021-02-18 14:38:23
494
原创 EntityFrameworkCore 原生Sql(SqlQuery扩展)解决方案
public static class EntityFrameworkCoreExtensions { private static DbCommand CreateCommand(DatabaseFacade facade, string sql, out DbConnection connection, params object[] parameters) { var conn = facade.GetDbConnection(...
2020-07-08 16:32:30
2609
原创 C# 查询时,条件集合中包含了子条件集合(List中包含了子List)
举例:六年级1班有一位 李狗蛋同学 和2班有一位 王美丽同学,校长想查这俩位实现方案:复制主体linq,进行Union查询List<Class> conditionArray=new List<Class>();conditionArray.Add(new Class(){ ClassName="六年级1班", Students=new List&...
2020-04-27 11:58:32
1711
原创 C# 水平分表后,分页逻辑解决办法
水平分库时,差不多都会使用一些规则去定义自动生成表通过查询反馈出以下数据TableName Count TableName1 10 TableName2 10 TableName3 10 public class TableDataCount { public int Count { get; set; } ...
2019-10-11 09:42:00
716
原创 C# List集合深度复制(流方式)
public List<T> Clone<T>(List<T> inputList) { BinaryFormatter Formatter = new BinaryFormatter(null, new StreamingContext(StreamingContextStates.Clone)); ...
2019-04-28 08:42:47
2995
原创 C# List进行切割成指定子List块
public List<List<T>> GetBlockList<T>(List<T> list,int blockSize=10) { List<List<T>> result = new List<List<T>>(); var tem...
2019-03-29 09:53:20
4506
原创 C# linq 多项分组 ,每一组根据条件(时间等)返回数据
var linq = from a in entities.Table group a by new { a.Column1, a.Column2} into temp let time= temp.Max(a => a.Column3) from row in temp where...
2018-12-20 13:59:21
3014
原创 ASP.NET WebAPI 接收参数时,时间类型(UTC)少8小时或者将UTC转本地时间(LocalTime)解决方式
直接切入问题:UI及前端传递的时间参数为:2000-06-26T16:00:00Z在Controller中如果请求的参数类型为时间类型的话,DateTime.Kind会是UTC,中国地区的会减少8个小时,所以需要调整一下WebApiConfig,将其设置为Local本地时间WebApiConfig添加: var json = GlobalConfiguration
2018-04-18 16:24:02
5276
原创 JAVA 简单的反射实现
Class bean1 = Class.forName(className);java.beans.BeanInfo info = java.beans.Introspector.getBeanInfo(bean1);java.beans.PropertyDescriptor pd[] = info.getPropertyDescriptors();for (int k = 0; k
2018-03-29 17:13:47
214
原创 C# 依赖注入中的 控制反转(Assembly)实现
对于刚接触依赖注入的人来说,什么面向切面,反射,依赖注入等等一时不好理解, 首先,都在说控制反转,既然有反转那么就会有控制正转,相信很多网上寻找控制反转资料中,很少有提到过正转。 正转也简单,就是我们通常调用的方式,由底层类库生产,逻辑层通过引用并进行new 实例化,进行调用,这就是正转,正转与之相反,不通过new直接调用,这就是反转,做过C#调用C++项目中的动态库时大概都知道,...
2018-03-29 16:53:18
1481
原创 VS 2015调试状态下,Bad Request - Invalid Hostname
当我们后台api开发者,与前端联调时,前端无法通过ip或者127.0.0.1 进行访问你的接口时,遇到的问题修改如下工程路径\.vs\config 文件夹下面的applicationhost.config 这个文件,找到site 那个节点,修改bindings 属性,这其实给在iis中编辑绑定是一样的意思。 <site name="DXMeteorological.Web" id="...
2018-03-23 16:22:43
3475
1
原创 C# 文件正由另一进程使用解决方案(流共享方式与锁方式)
其主要触发的原因,文件正在被读写时,读写时间过大没有来得及关闭读写流,这时另一程序进行访问,文件被前一个程序独占1.将文件流变为共享:FileStream fs = new FileStream(path, FileMode.Open, FileAccess.Read, FileShare.ReadWrite);StreamReader sr = new StreamReader(
2018-03-15 16:50:09
5695
原创 Linq TO EF 联合查询JOIN简单示例
var result = ef.M_Record.Where(where).GroupBy(g => new { g.F_FireID}) .Select(s => new { MR_ID =s.Max(m=>m.MR_ID)}) .Join(ef.M_Record, L => E.MR_ID,
2018-03-09 13:55:02
2407
原创 Base64文件上传服务端开发源码
using System;using System.Configuration;using System.IO;using System.Security.Cryptography;using System.Web;namespace Factory{ public class FileBase { //文件在服务器存放地址 publ...
2018-03-09 13:49:34
221
原创 C# 后台使用HttpWebRequest发送POST请求帮助类
using System;using System.Collections.Generic;using System.IO;using System.Net;using System.Text;namespace Utils{ public class RequestHelper { public static string SendHttpReque
2018-03-09 13:33:23
11145
1
原创 C# Web Service 不使用服务引用直接调用方法
using Microsoft.CSharp;using System;using System.CodeDom;using System.CodeDom.Compiler;using System.IO;using System.Net;using System.Text;using System.Web.Services.Description;namespace Utils
2018-03-09 13:26:49
4378
原创 Linq TO Entity Or Linq TO EF 中的where参数化查询
using System;using System.Linq.Expressions;namespace Utils{ /// /// 统一ParameterExpression /// public class ParameterReplacer : ExpressionVisitor { public ParameterRe
2018-03-09 13:20:49
1572
原创 Sql Server 自增列无法写入或 无法将已有数据的列修改为自增的方法
beginset identity_insert DemoIdentity oninsert into DemoIdentity(Def_ID,Def_Value) values(10,'测试');set identity_insert DemoIdentity offend
2018-03-09 13:16:20
2514
原创 WebAPI与SignalR开发中的跨域要注意的细节
app.Map("/signalr", map => { map.UseCors(CorsOptions.AllowAll); var hubConfiguration = new HubConfiguration { }; ...
2018-03-09 13:10:32
3380
原创 C# HttpListener 开发服务器示例
private static HttpListener listener; public static void demo() { if (listener == null) { listener = new HttpListener();
2016-06-04 20:16:29
3772
原创 C# 如何找出所有memcached里的所有存放的元素
/// <summary> /// 遍历出所有元素 /// </summary> /// <param name="tagName">customer_,device_ 等</param> /// <returns>Hashtable 数据对象,根据tagN...
2016-04-12 15:41:40
426
空空如也
TA创建的收藏夹 TA关注的收藏夹
TA关注的人