小编Nau*_*zet的帖子

现在有办法将TVP传递给.Net Core上的精致吗?

我正在使用.net核心和dapper,第一个没有DataTables,第二个使用它们用于TVP.

我试图将a转换List<T>为a List<SqlDataRecord>,使用此列表创建一个SqlParameter然后将其转换为DynamicParameter但遗憾的是我得到了:The member of type Microsoft.SqlServer.Server.SqlDataRecord cannot be used as a parameter value

UPDATE

玩了一下之后IDynamicParameters,我就开始了.

扩展方法 IEnumerable

public static DynamicWrapper toTVP<T>(this IEnumerable<T> enumerable, string tableName, string typeName)
{
    List<SqlDataRecord> records = new List<SqlDataRecord>();
    var properties = typeof(T).GetProperties().Where(p => Mapper.TypeToSQLMap.ContainsKey(p.PropertyType));
    var definitions = properties.Select(p => Mapper.TypeToMetaData(p.Name, p.PropertyType)).ToArray();
    foreach (var item in enumerable)
    {
        var values = properties.Select(p => p.GetValue(item, null)).ToArray();
        var schema = new SqlDataRecord(definitions);
        schema.SetValues(values);
        records.Add(schema);
    }

    SqlParameter result = new SqlParameter(tableName, SqlDbType.Structured); …
Run Code Online (Sandbox Code Playgroud)

c# sql reflection dapper .net-core

17
推荐指数
1
解决办法
2994
查看次数

如何在c#中反转逻辑锯齿状数组的值?

下午好,我有一个带有真值和假值(或0和1)的交叉#jagged数组,我想要反转这些值:

1 1 1 1
0 1 1 0
1 1 1 1
1 0 0 1
Run Code Online (Sandbox Code Playgroud)

成为:

0 0 0 0
1 0 0 1
0 0 0 0
0 1 1 0
Run Code Online (Sandbox Code Playgroud)

是否有一种简单的方法可以不循环它?像!myJaggedArray?

c# arrays math matrix jagged-arrays

6
推荐指数
2
解决办法
384
查看次数

dotnet.exe锁定SonarScanner.MSBuild.Common.dll

晚上好,

我在Jenkins的2.1项目中使用.Net Core 2.0版本https://docs.sonarqube.org/display/SCAN/Analyzing+with+SonarQube+Scanner+for+MSBuild:

withSonarQubeEnv('SonarQubeMain') {
    bat "dotnet ${globals.SONAR_QUBE_MSBUILD_PATH}\\SonarScanner.MSBuild.dll begin /k:\"${globals.SONAR_QUBE_PROJECT}\" /d:sonar.host.url=${globals.SONAR_HOST_URL} /d:sonar.cs.xunit.reportsPaths=\"XUnit.xml\" /d:sonar.cs.opencover.reportsPaths=\"coverage.xml\"
}

bat "dotnet build --version-suffix ${env.BUILD_NUMBER}"

dir('test/mytestprojecthere') {
    bat 'D:\\OpenCover\\OpenCover.Console.exe -target:"c:\\Program Files\\dotnet\\dotnet.exe" -targetargs:"xunit --no-build -xml XUnit.xml" -output:coverage.xml -oldStyle -filter:"-[*Tests*]*" -register:user'
}
withSonarQubeEnv('SonarQubeMain') {
    bat "dotnet ${globals.SONAR_QUBE_MSBUILD_PATH}\\SonarScanner.MSBuild.dll end"
}
Run Code Online (Sandbox Code Playgroud)

它适用于第一个构建,但在下一个构建中,它失败了:

Failed to create an empty directory 'D:\Jenkins\workspace\xxxxxxxx\.sonarqube'. 
Please check that there are no open or read-only files in the directory and that you have the necessary read/write permissions.

Detailed error message: Access to the path …
Run Code Online (Sandbox Code Playgroud)

sonarqube sonarqube-scan

4
推荐指数
3
解决办法
2028
查看次数