我需要能够从批处理中删除特定用户(可能有活动会话)而无需任何用户交互.我不关心活动会话,并希望将它们删除并回滚.对于Microsoft SQL,我将使用一行执行类似的任务:
osql -E -S localhost -b -Q "use master if ((select name from sysdatabases where name='%DB%') is not null) begin alter database [%DB%] set single_user with rollback immediate drop database [%DB%] end"
Run Code Online (Sandbox Code Playgroud)
我如何为Oracle(Windows上的10g XE)做到这一点?
我目前的批次是:
sqlplus sys/*** as SYSDBA @delete1.sql >delete.log
sqlplus sys/***@XE as SYSDBA @delete2.sql >>delete.log
Run Code Online (Sandbox Code Playgroud)
其中delete1.sql:
startup force;
exit;
Run Code Online (Sandbox Code Playgroud)
和delete2.sql:
drop user MYUSER cascade;
exit;
Run Code Online (Sandbox Code Playgroud)
与MSSQL解决方案的瞬间相比,这很难看,并且耗时太长.
广告中提到的FP功能之一是程序"默认并行",并且自然适合现代多核处理器.实际上,减少树的性质是平行的.但是,我不明白它如何映射到多线程.考虑以下片段(伪代码):
let y = read-and-parse-a-number-from-console
let x = get-integer-from-web-service-call
let r = 5 * x - y * 4
write-r-to-file
Run Code Online (Sandbox Code Playgroud)
翻译器如何确定哪个树分支应该在一个线程上运行?在你获得x或者在单独的线程上y减少5 * x或y * 4表达式是愚蠢的(即使我们从线程池中获取它),不是吗?那么不同的功能语言如何处理呢?
parallel-processing multithreading functional-programming lang
var sample = new
{
Time = DateTime.Now,
Name = "Hello"
};
Trace.TraceInformation("{0}", sample);
Run Code Online (Sandbox Code Playgroud)
输出为
ProcessInvocation86.exe信息:0:{Time = 04.11.2012 22:07:52,Name = Hello}
我想在我的应用程序中使用不同的格式.有没有办法在C#中更改匿名对象的ToString()实现?也许每个AppDomain或某些静态字段?
[IExceptionLogger][1]当从控制器操作抛出异常时,我的异常记录器实现被调用两次.
context.RequestContext.Configuration.Services.GetServices(typeof(IExceptionLogger))
Run Code Online (Sandbox Code Playgroud)
这会返回一个条目,所以我确定只注册了一个记录器实例.我不希望我的未处理异常被记录两次,我不认为这是预期的默认行为.我如何解决导致它的原因?
如果我在LogAsync()方法中设置断点,则callstack会[External Code]在两个调用中显示.
[RoutePrefix("test")]
public class MyController : ApiController
{
[HttpGet, AllowAnonymous]
[Route("test")]
public string GetTest()
{
throw new InvalidOperationException("Shit happens");
}
}
Run Code Online (Sandbox Code Playgroud)
记录器注入如下:
config.Services.Add(typeof(IExceptionLogger), new WebApiExceptionLogger());
public class WebApiExceptionLogger : IExceptionLogger
{
private readonly ILoggingService loggingService;
public WebApiExceptionLogger()
{
this.loggingService = ServiceContainer.Factory.Resolve<ILoggingService>();
}
public Task LogAsync(ExceptionLoggerContext context, CancellationToken cancellationToken)
{
this.loggingService.Log(LogLevel.Error, this.GetType().Name, context.Exception, "Ship has just happened");
return Task.FromResult(true);
}
}
Run Code Online (Sandbox Code Playgroud) .net error-handling logging asp.net-web-api asp.net-web-api2
IEnumerable<T>,IComparable<T>还有一些现在是类型变体.IList<T>,ICollection<T>还有很多其他的不是.为什么?
我需要将我的服务器与非WCF客户端集成,并建议更改标头中的SOAP版本.这可以通过<textMessageEncoding messageVersion="Soap11" />自定义绑定上的元素完成,所以我需要转换我的当前basicHttpBinding.我怎样才能做到这一点?
<basicHttpBinding>
<binding>
<security mode="TransportWithMessageCredential">
<transport clientCredentialType="Windows"/>
<message clientCredentialType="UserName" />
</security>
</binding>
</basicHttpBinding>
Run Code Online (Sandbox Code Playgroud) 与此方法async/await相比,将L2S与新C#5 关键字一起使用的最佳做法是什么?在网上找不到任何内容.
我有一系列键/值对,我想要返回自定义排序(不是按键):
public IHttpActionResult GetStuff() {
bla-bla-bla
.ToDictionary(x => x.Code, x => x.Desc);
}
Run Code Online (Sandbox Code Playgroud)
生成以下JSON:
{
"1": "ZZZ",
"3": "AAA",
"8": "CCC",
}
Run Code Online (Sandbox Code Playgroud)
响应始终由密钥排序,因为据我所知Dictionary<K, T>,不保证特定的排序.如果我改为返回已排序的KeyValuePair<K, T>Web API 列表,则会生成另一个布局:
[
{ "Key": 3, "Value": "AAA"},
{ "Key": 8, "Value": "CCC"},
{ "Key": 1, "Value": "ZZZ"},
]
Run Code Online (Sandbox Code Playgroud)
由于额外的有效载荷,我不想要.那么如何返回类似于第一个样本的类似字典的键/值序列?
我正在尝试读取标题位于第 3 行的 CSV 文件:
some crap line
some empty line
COL1,COL2,COl3,...
val1,val2,val3
val1,val2,val3
Run Code Online (Sandbox Code Playgroud)
如何告诉CSVHelper标题不在第一行?
我试图跳过 2 行,Read()但随后的调用ReadHeader()引发了一个异常,表明标题已被读取。
using (var csv = new CsvReader(new StreamReader(stream), csvConfiguration)) {
csv.Read();
csv.Read();
csv.ReadHeader();
.....
Run Code Online (Sandbox Code Playgroud)
如果我设置csvConfiguration.HasHeaderRecord为false ReadHeader()再次失败。
.net ×6
c# ×2
.net-4.5 ×1
async-await ×1
covariance ×1
csv ×1
csvhelper ×1
dictionary ×1
generics ×1
javascript ×1
lang ×1
linq-to-sql ×1
logging ×1
maintenance ×1
oracle ×1
postman ×1
sorting ×1
types ×1
wcf ×1
wcf-binding ×1
wcf-security ×1