mirror of
https://github.com/nsnail/FreeSql.git
synced 2025-06-18 20:08:15 +08:00
测试Array常用查询函数
This commit is contained in:
@ -2,24 +2,30 @@
|
||||
using FreeSql.ClickHouse.Curd;
|
||||
using FreeSql.Internal.CommonProvider;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq.Expressions;
|
||||
using System.Threading;
|
||||
using System.Threading.Tasks;
|
||||
using FreeSql.DataAnnotations;
|
||||
|
||||
public static partial class FreeSqlClickHouseGlobalExtensions
|
||||
{
|
||||
|
||||
/// <summary>
|
||||
/// 特殊处理类似 string.Format 的使用方法,防止注入,以及 IS NULL 转换
|
||||
/// </summary>
|
||||
/// <param name="that"></param>
|
||||
/// <param name="args"></param>
|
||||
/// <returns></returns>
|
||||
public static string FormatClickHouse(this string that, params object[] args) => _clickHouseAdo.Addslashes(that, args);
|
||||
public static string FormatClickHouse(this string that, params object[] args) =>
|
||||
_clickHouseAdo.Addslashes(that, args);
|
||||
|
||||
static FreeSql.ClickHouse.ClickHouseAdo _clickHouseAdo = new FreeSql.ClickHouse.ClickHouseAdo();
|
||||
|
||||
/// <summary>
|
||||
/// Clickhouse limit by
|
||||
/// </summary>
|
||||
public static ISelect<T> LimitBy<T>(this ISelect<T> that, Expression<Func<T, object>> selector, int limit, int offset = 0)
|
||||
public static ISelect<T> LimitBy<T>(this ISelect<T> that, Expression<Func<T, object>> selector, int limit,
|
||||
int offset = 0)
|
||||
{
|
||||
if (limit <= 0 && offset <= 0) return that;
|
||||
var s0p = that as ClickHouseSelect<T>;
|
||||
@ -34,6 +40,7 @@ public static partial class FreeSqlClickHouseGlobalExtensions
|
||||
{
|
||||
s0p._orderby = oldOrderBy;
|
||||
}
|
||||
|
||||
return that;
|
||||
}
|
||||
|
||||
@ -52,4 +59,36 @@ public static partial class FreeSqlClickHouseGlobalExtensions
|
||||
s0p._sample = $"SAMPLE {k}";
|
||||
return that;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 批量快速插入
|
||||
/// </summary>
|
||||
/// <typeparam name="T"></typeparam>
|
||||
/// <param name="that"></param>
|
||||
/// <returns></returns>
|
||||
public static async Task<int> ExecuteBulkCopyAsync<T>(this IInsert<T> that) where T : class
|
||||
{
|
||||
try
|
||||
{
|
||||
var insert = that as ClickHouseInsert<T>;
|
||||
await insert.InternalBulkCopyAsync();
|
||||
}
|
||||
catch (Exception e)
|
||||
{
|
||||
throw e;
|
||||
}
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 批量快速插入
|
||||
/// </summary>
|
||||
/// <typeparam name="T"></typeparam>
|
||||
/// <param name="insert"></param>
|
||||
/// <returns></returns>
|
||||
public static int ExecuteBulkCopy<T>(this IInsert<T> insert) where T : class
|
||||
{
|
||||
return ExecuteBulkCopyAsync(insert).ConfigureAwait(false).GetAwaiter().GetResult();
|
||||
}
|
||||
}
|
||||
|
Reference in New Issue
Block a user