是否有一个agregate函数返回组中的任何值.我可以使用MIN
或者MAX
,但如果可能的话,我宁愿避免开销,因为它是一个文本字段.
我的情况是错误日志摘要.错误按错误类型分组,并显示每个组的错误文本示例.使用哪个错误消息作为示例并不重要.
SELECT
ref_code,
log_type,
error_number,
COUNT(*) AS count,
MIN(data) AS example
FROM data
GROUP BY
ref_code,
log_type,
error_number
Run Code Online (Sandbox Code Playgroud)
我可以替换什么MIN(data)
来不必比较100,000的varchar(2000)值?
我已在IIS 7.0上部署了我的应用程序.我想在我的应用程序中使用共享的Image文件夹,因此我在IIS上部署的应用程序中创建了一个虚拟目录.
我将此虚拟目录的物理路径设置为另一台计算机上的共享文件夹.现在,当我尝试浏览此共享文件夹中的任何图像时,我收到以下错误:
HTTP错误500.19 - 内部服务器错误
无法访问请求的页面,因为页面的相关配置数据无效.
详细错误信息:
模块 IIS Web核心
通知 BeginRequest
处理程序尚未确定
错误代码 0x8007052e
配置错误无法读取配置文件
配置文件 \?\ UNC\WINSERVER1\hpu_images_staging\web.config
请求的URL http:// [IPAddress]/Images/Temp_Harsh /photos/086b88b9-a228-4e0d-ba29-436c74ff5258.jpg
物理路径\WINSERVER1\hpu_images_staging\vetphotos\086b88b9-a228-4e0d-ba29-436c74ff5258.jpg
登录方法尚未确定
登录用户尚未确定
失败请求跟踪日志目录 C :\的Inetpub \日志\ FailedReqLogFiles
我该如何解决这个问题?
我发现通过PowerShell管道将string
对象传递给函数会将它们转换为对象.如果我将对象作为参数传递,它会保留其类型.展示:
我有以下PowerShell函数,它显示对象的类型和值:
function TestFunction {
param (
[Parameter(
Position=0,
Mandatory=$true,
ValueFromPipeline=$true
)] $InputObject
)
Echo $InputObject.GetType().Name
Echo $InputObject
}
Run Code Online (Sandbox Code Playgroud)
我运行此脚本来测试函数:
[string[]] $Array = "Value 1", "Value 2"
# Result outside of function.
Echo $Array.GetType().Name
Echo $Array
Echo ""
# Calling function with parameter.
TestFunction $Array
Echo ""
# Calling function with pipeline.
$Array | TestFunction
Run Code Online (Sandbox Code Playgroud)
这会产生输出:
String[]
Value 1
Value 2
String[]
Value 1
Value 2
String
Value 2
Run Code Online (Sandbox Code Playgroud)
编辑:我如何使用管道将整个数组传递给函数?
我正在编写单元测试来测试在 GUI 中键入的数据是否经过验证和正确记录。目前我正在使用这样的代码:
using (MyControl target = new MyControl())
{
PrivateObject accessor = new PrivateObject(target);
TextBox inputTextBox = (TextBox)accessor.GetField("InputTextBox");
string expected, actual;
expected = "Valid input text.";
inputTextBox.Text = expected;
// InputTextBox.TextChanged sets FieldData.Input
actual = target.FieldData.Input;
Assert.AreEqual(expected, actual);
}
Run Code Online (Sandbox Code Playgroud)
但我宁愿使用 Validated 事件而不是 TextChanged 事件。
using (MyControl target = new MyControl())
{
PrivateObject accessor = new PrivateObject(target);
TextBox inputTextBox = (TextBox)accessor.GetField("InputTextBox");
string expected, actual;
bool valid;
expected = "Valid input text.";
inputTextBox.Text = expected;
valid = inputTextBox.Validate();
// InputTextBox.Validating returns …
Run Code Online (Sandbox Code Playgroud) 我正在编写一个使用Excel的.Net应用程序.可以接受来自'97或更高版本的任何版本的Excel,但我不知道任何特定客户端将具有哪个版本.通过引导程序安装Microsoft Office PIA是没有问题的.
我应该在安装包中包含哪个版本的PIA?我是否需要每个PIA版本,或者一个PIA版本是否涵盖所有必需的Excel版本?
使用 PowerShell,如何按大小对所有文件夹中的所有文件进行排序?每当我使用 Get-ChildItem 的结果时,即使将其保存到变量并进行修改,它也会按目录对所有文件进行分组。即使这样,文件也不会在每个目录中排序。
$files = Get-ChildItem -File -Filter *.bat -Path C:\git -Recurse
Sort-Object -InputObject $files -Property Length
Run Code Online (Sandbox Code Playgroud) 如果我有一组字符串常量我想要存储类似于a enum
,最好使用a struct
还是static class
?例如:
public struct Roman
{
public const string One = "I";
public const string Five = "V";
public const string Ten = "X";
}
public static class Roman
{
public const string One = "I";
public const string Five = "V";
public const string Ten = "X";
}
Run Code Online (Sandbox Code Playgroud) 我有以下 Oracle SQL 查询。给定一个名字和姓氏,它会以任一顺序查找具有一个名字和另一个名字首字母的所有记录。我创建了该score
列以将可能的匹配项放在结果集的顶部。
SELECT
surname,
givenname,
(CASE WHEN surname = 'Smith' THEN 2 ELSE 0)
+ (CASE WHEN givenname = 'John' THEN 1 ELSE 0)
AS score
FROM person
WHERE (surname = 'Smith' AND givenname LIKE 'J%')
OR (surname LIKE 'S%' AND givenname = 'John')
OR (surname = 'John' AND givenname LIKE 'S%')
OR (surname LIKE 'J%' AND givenname = 'Smith')
ORDER BY
score DESC,
surname ASC,
givenname ASC;
Run Code Online (Sandbox Code Playgroud)
问题是score
在+
. IDE 报告:
语法错误,预期: …
我正在尝试使用C#从Google Analytics下载指标数据,并且正在使用OAuth 2.0执行用户身份验证.我正在使用已安装的应用程序授权流程,该流程需要登录Google并将代码复制并粘贴到应用程序中.我正在关注从google-api-dotnet-client获取的代码:
private void DownloadData()
{
Service = new AnalyticsService(new BaseClientService.Initializer() {
Authenticator = CreateAuthenticator(),
});
var request = service.Data.Ga.Get(AccountID, StartDate, EndDate, Metrics);
request.Dimensions = Dimensions;
request.StartIndex = 1;
request.MaxResults = 10000;
var response = request.Execute(); // throws Google.GoogleApiException
}
private IAuthenticator CreateAuthenticator()
{
var provider = new NativeApplicationClient(GoogleAuthenticationServer.Description) {
ClientIdentifier = "123456789012.apps.googleusercontent.com",
ClientSecret = "xxxxxxxxxxxxxxxxxxxxxxxx",
};
return new OAuth2Authenticator<NativeApplicationClient>(provider, Login);
}
private static IAuthorizationState Login(NativeApplicationClient arg)
{
// Generate the authorization URL.
IAuthorizationState state …
Run Code Online (Sandbox Code Playgroud) 我最近从我的机器上卸载了 Service Fabric 及其 SDK。但是,它留下了机器范围的包源:
Microsoft Azure Service Fabric SDK
C:\Program Files\Microsoft SDKs\Service Fabric\packages
此文件夹不再存在。它导致我的构建失败。取消选中此选项作为可用源似乎不会在会话之间持续存在。
如何永久删除此包源?
在 Visual Studio 选项中,此包源无法删除。我可以取消它,但这似乎不是持久的。
我的 NuGet.config 也没有引用它。我在我的计算机上找不到另一个 NuGet.config。
<?xml version="1.0" encoding="utf-8"?>
<configuration>
<packageSources>
<add key="nuget.org" value="https://api.nuget.org/v3/index.json" protocolVersion="3" />
<add key="Microsoft Visual Studio Offline Packages" value="C:\Program Files (x86)\Microsoft SDKs\NuGetPackages\" />
</packageSources>
<packageRestore>
<add key="enabled" value="True" />
<add key="automatic" value="True" />
</packageRestore>
<bindingRedirects>
<add key="skip" value="False" />
</bindingRedirects>
<packageManagement>
<add key="format" value="0" />
<add key="disabled" value="False" />
</packageManagement>
</configuration>
Run Code Online (Sandbox Code Playgroud)