当前位置: 首页 > wzjs >正文

看网站是不是WP做的seo优化排名方法

看网站是不是WP做的,seo优化排名方法,做网站用的语言,莱西做网站的大家都知道,对于SQL Server IN是有限制条件的,如果IN里面的内容过多,在执行的时候会被自动截断,因而导致查询到的结果不是实际需要的结果。 select * from Payments where Id in (1,2,3,4,...) 为了解决上面的限制,可以…

大家都知道,对于SQL Server IN是有限制条件的,如果IN里面的内容过多,在执行的时候会被自动截断,因而导致查询到的结果不是实际需要的结果。

select * from Payments where Id in (1,2,3,4,...)

为了解决上面的限制,可以改为利用用户自定义数据类型解决。

具体内容如下:

1. Create User-Defined Data Types

CREATE TYPE [dbo].[IdTable] AS TABLE([Id] [int] NOT NULL
)
GO

2. Create Store Procedure which use IdTable as Input paramter.

CREATE PROCEDURE [dbo].[SP_GET_PAYMENTS]                  @PaymentIds [dbo].[IdTable] READONLY                 
AS   
BEGIN  select p.Id,p.DueDate   from @PaymentIds tp     join Payments p with (nolock) on tp.Id=p.Id 
END  

3. Parameter convert to IdTable. SQLMapper Extension

  public static class Extensions{/// <summary>/// This extension converts an enumerable set to a Dapper TVP/// </summary>/// <typeparam name="T">type of enumerbale</typeparam>/// <param name="enumerable">list of values</param>/// <param name="typeName">database type name</param>/// <param name="orderedColumnNames">if more than one column in a TVP, /// columns order must mtach order of columns in TVP</param>/// <returns>a custom query parameter</returns>public static SqlMapper.ICustomQueryParameter AsTableValuedParameter<T>(this IEnumerable<T> enumerable,string typeName, IEnumerable<string> orderedColumnNames = null){var dataTable = new DataTable();if (typeof(T).IsValueType || typeof(T).FullName.Equals("System.String")){dataTable.Columns.Add(orderedColumnNames == null ?"NONAME" : orderedColumnNames.First(), typeof(T));foreach (T obj in enumerable){dataTable.Rows.Add(obj);}}else{PropertyInfo[] properties = typeof(T).GetProperties(BindingFlags.Public | BindingFlags.Instance);PropertyInfo[] readableProperties = properties.Where(w => w.CanRead).ToArray();if (readableProperties.Length > 1 && orderedColumnNames == null)throw new ArgumentException("Ordered list of column names must be provided when TVP contains more than one column");var columnNames = (orderedColumnNames ??readableProperties.Select(s => s.Name)).ToArray();foreach (string name in columnNames){dataTable.Columns.Add(name, readableProperties.Single(s => s.Name.Equals(name)).PropertyType);}foreach (T obj in enumerable){dataTable.Rows.Add(columnNames.Select(s => readableProperties.Single(s2 => s2.Name.Equals(s)).GetValue(obj)).ToArray());}}return dataTable.AsTableValuedParameter(typeName);}}

4. Dapper code

Dapper version: 2.1.37

using System;
using System.Configuration;
using System.Collections.Generic;
using System.Data;
using System.Linq;
using System.Reflection;
using Dapper;
using log4net;
using Microsoft.Data.SqlClient;
using static Dapper.SqlMapper;public List<T> QueryEntitiesNoUTC<T>(string sqlCommand, object parameters, CommandType commandType, int commandTimeout = 60){using (SqlConnection Connection = GetSqlConnection(ConfigurationManager.ConnectionStrings["Default"].ConnectionString)){try{Connection.Open();List<T> returnValues = Connection.Query<T>(sqlCommand, parameters, commandType: commandType, commandTimeout: GetCommandTimeout(commandTimeout)).ToList<T>();Connection.Close();Connection.Dispose();return returnValues;}catch (Exception e){Log.Error(e);throw;}finally{Connection.Close();Connection.Dispose();}}}

5. C# call Demo

        public static List<PaymentDto> GetPayment(List<int> paymentIds){if (paymentIds == null || paymentIds.Count == 0){return new();}var param = new { PaymentIds = paymentIds.AsTableValuedParameter("dbo.IdTable", new List<string>() { "Id" }) };var result = dapperHelper.QueryEntitiesNoUTC<PaymentDto>("SP_GET_PAYMENTS", param, CommandType.StoredProcedure, SqlConstants.GetBiggerRecordsTimeoutSeconds);return result;}

如果是多个参数:

var param = new { PaymentIds= paymentIds.AsTableValuedParameter("dbo.IdTable", new List<string>() { "Id" }), Status= status};

http://www.dtcms.com/wzjs/407362.html

相关文章:

  • 个人网站租用服务器荆州百度推广
  • 闵行区网站开发谷歌搜索引擎入口2021
  • 苏州市著名网站制作100个电商平台
  • 西部数码网站备案查询百度推广费用多少钱
  • 网站注册费用全网搜索引擎优化
  • 免备案域名是危险网站西点培训学校
  • 网站建设和网站开发2022年度最火关键词
  • 做英国代购的公司网站b2b电商平台有哪些
  • 俄文手机网站制作指数基金定投怎么买
  • 网站开发经营范围微博指数查询
  • 建网站上海网络营销的优势是什么
  • 网站做不了301重定向南宁百度网站推广
  • 4399网站开发销售策略和营销策略
  • 北京公司网站建设报价西安网站建设公司排行榜
  • 可以免费做网站吗北京网络网站推广
  • 网站建设技术文章一站式网络营销
  • 南宁网站备案网络营销的方式都有哪些
  • 仿模板电影网站站长论坛
  • 网络客服怎么做seo助手
  • 哪些网站用python做的小程序开发系统
  • 怎样做软件网站中国今天新闻最新消息
  • wordpress远程调用cdnseo收索引擎优化
  • 网站怎么在百度做推广销售网络平台
  • 郑州专业网站制作的公司哪家好百度网络营销中心官网
  • 做包装的网站泉州百度网络推广
  • 在国外做热情网站的风险在线crm
  • 网站无法做301重定向网店运营在哪里学比较好些
  • 自贡建设监督质量网站腾讯云建站
  • 杭州软件制作推广seo是什么意思
  • p2p网站建设时间神马网站快速排名案例