我有3个数据库DBDev,DBStaging和DBProduction.在我的应用程序内部,我为每个数据库创建了3个edmx.每个DB都有一个匹配的实体,如下所示:DBDev - > DEVEntities,DBStaging - > StagingEntities或DBProduction - > ProductionEntities
我在web.config中选择要通过此访问的数据库:
<connectionStrings configSource="Configs\DBDev.config" /> <!-- or DBStaging or DBProduction-->
Run Code Online (Sandbox Code Playgroud)
我将我的所有数据库访问路由到一个静态类:DBAccess.当我需要指向特定的上下文时,我手动执行此操作:
private static DEVEntities db = new DEVEntities();
Run Code Online (Sandbox Code Playgroud)
要么
private static StagingEntities db = new StagingEntities();
Run Code Online (Sandbox Code Playgroud)
要么
private static ProductionEntities db = new ProductionEntities();
Run Code Online (Sandbox Code Playgroud)
什么是更智能的方式来指向所需的上下文而无需手动更改它?
我试图阻止Enter提交我的按钮,而是让它指向另一个功能.我尝试Enter通过主机监听器捕获,然后preventDefault()对其进行操作以阻止其触发.
我的组件中的模板如下所示:
<mat-dialog-content class="dialog-content">{{data.content | translate}}</mat-dialog-content>
<div>
<mat-button-toggle-group>
<button type="button" matDialogClose (click)="dialogRef.close()">{{uppercase }}</button>
<button type="button" (click)="dialogRef.close(true)" cdkFocusInitial>{{uppercase}}</button>
</mat-button-toggle-group>
</div>
Run Code Online (Sandbox Code Playgroud)
在我的组件代码的顶部:
export enum KEY_CODE {
ENTER_KEY = 13
}
Run Code Online (Sandbox Code Playgroud)
在我的导出类中:
@HostListener('window:keyup', ['$event'])
keyEventUp(event: KeyboardEvent) {
if (event.keyCode === KEY_CODE.ENTER_KEY) {
event.preventDefault();
event.stopPropagation();
return false;
}
}
Run Code Online (Sandbox Code Playgroud) 我有这一点来检索两个用户之间的所有消息:
let user1 = "john"
let user2 = "mark"
let predicateUser1To2 = NSPredicate(format: "user1 == %@", user1)
let predicateUser2From1 = NSPredicate(format: "user2 == %@", user2)
let predicateUser2To1 = NSPredicate(format: "user2 == %@", user1)
let predicateUser1From2 = NSPredicate(format: "user1 == %@", user2)
let predicate1To2 = NSCompoundPredicate(andPredicateWithSubpredicates: [predicateUser1To2, predicateUser2From1])
let predicate2To1 = NSCompoundPredicate(andPredicateWithSubpredicates: [predicateUser1From2, predicateUser2To1])
let predicate = NSCompoundPredicate(orPredicateWithSubpredicates: [predicate1To2, predicate2To1])
let query = CKQuery(recordType: "Chat", predicate: predicate)
Run Code Online (Sandbox Code Playgroud)
但这会引发以下错误。看来它得到正确的评估,为什么会出错!?
***由于未捕获的异常'CKException'而终止应用程序,原因:'无效谓词:(user1 ==“ john” AND user2 ==“ mark”)OR(user1 ==“ mark” AND user2 ==“ john”) …
我正在创建另一个组件 (ParentComponent2),它需要与 ParentComponent1 所需的完全相同的 html,因此我创建了一个子组件并将其扩展到我需要的位置:
我的父组件
import { Component, Input } from '@angular/core'
import { CategoryList } from "./metadata.service.dtos"
import { MyChildComponent } from "./my-child.component"
@Component({
selector: "my-parent",
templateUrl: "/js/app/templates/my_parent.html"
})
export class ParentComponent1 {
categories: CategoryList[];
this.categories = this.metadataService.categories;
}
Run Code Online (Sandbox Code Playgroud)
我的父母模板
<ul materialize="collapsible" class="collapsible" data-collapsible="collapsible" [materializeParams]="params">
<li>
<div class="collapsible-header">
My Products
</div>
<div class="collapsible-body">
<div class="card horizontal hoverable lighten-4 my-product" *ngFor="let product of products">
<my-single-product [categories]="categories"></my-single-product>
</div>
</div>
</li>
</ul>
Run Code Online (Sandbox Code Playgroud)
我的孩子组件
import { Component, Input } from '@angular/core'
import …Run Code Online (Sandbox Code Playgroud) 我正在使用 Angular Material 创建我的切换面板。我仍然希望我的面板在单击箭头时展开和收缩,但是当我单击面板标题中的任何位置时我不会,因为我想在顶部添加一个复选框。目前,当我单击复选框时,会在单击复选框时触发面板的切换事件。复选框的“更改”事件随后仍会触发。
我不介意仅在单击其箭头时让面板切换,如何在单击顶部的任意位置时停止触发面板的切换?
HTML
<mat-expansion-panel #panel
(opened)="togglePanel()"
(closed)="togglePanel()">
<mat-expansion-panel-header>
<mat-panel-title>
<mat-checkbox (change)="onCheckChanged($event)">
<label>Options 1</label>
</mat-checkbox>
</mat-panel-title>
<mat-panel-description></mat-panel-description>
</mat-expansion-panel-header>
</mat-expansion-panel>
Run Code Online (Sandbox Code Playgroud)
打字稿
togglePanel() {
// this event fires before the onCheckChanged event
}
onCheckChanged(event: MatCheckboxChange) {
// this event fires after the togglePanel event
}
Run Code Online (Sandbox Code Playgroud) 我有一个 .net core 3.1 Console 项目。我正在尝试将其设置为使用 NLog。我使用 2 个目标,数据库和文件。我可以写入文件,但不能写入数据库。我确信连接字符串是正确的,因为我在其他项目中使用它,但它们是在 4.7 框架中编写的。
这是我的 app.config 设置:
<connectionStrings>
<add name="NLog" connectionString="Data Source=mySource;Initial Catalog=MyLogging;Integrated Security=SSPI;" />
</connectionStrings>
Run Code Online (Sandbox Code Playgroud)
这是我尝试在目标中设置它:
<?xml version="1.0" encoding="utf-8" ?>
<nlog xmlns="http://www.nlog-project.org/schemas/NLog.xsd"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
autoReload="true"
internalLogLevel="Info"
internalLogFile="c:\temp\nlog-internal.log">
<!-- enable asp.net core layout renderers -->
<extensions>
<add assembly="NLog.Web.AspNetCore"/>
</extensions>
<!-- the targets to write to -->
<targets>
<target name="database" xsi:type="Database" connectionString="${configsetting:name=NLog}" commandType="StoredProcedure" commandText="[dbo].[MyLogEntry]">
</target>
</targets>
<rules>
<logger name="*" minlevel="Trace" writeTo="Database" />
</rules>
</nlog>
Run Code Online (Sandbox Code Playgroud)
来自 c:\temp\nlog-internal.log 的错误消息是:
2021-02-10 16:11:48.3381 Error DatabaseTarget(Name=database): Error when writing to …Run Code Online (Sandbox Code Playgroud) connection-string app-config nlog asp.net-core-configuration asp.net-core-3.1
有了TableLayoutPanel的所有属性,我不知道为什么这不简单.
我有一个tableLayoutPanel有两列.我试图在第一列中放置一个标签,以将其用作标题.我想将它放在相对于列的特定坐标中,但我不知道如何使用边距或填充属性.必须有一个比这更简单的方法.我尝试过使用锚点和停靠属性,但没有用.
有人能告诉我一个如何做到这一点的例子吗?为什么我不能将标签拖到我想要的位置?
根据本教程:如何使用iOS中的Blob存储,我应该使用Azure命令行界面(Azure CLI)命令:
$ azure存储帐户连接字符串显示"mystorage"
显示我的存储帐户的连接字符串,但我收到此错误:
info:执行命令storage account connectionstring show +获取存储帐户密钥错误:找不到存储帐户'mystorage'.info:
错误信息已记录到/Users/user/.azure/azure.err错误:storage account connectionstring show命令失败
我的存储是使用新的azure门户创建的.我注意到如果我使用经典门户(旧版)创建存储,该命令将运行正常,并返回连接字符串.
这是另一个可能与此有关的奇怪行为.我使用新门户创建的存储未显示在经典门户中,但我在类中创建的存储显示在新门户中.这是怎么回事?如何为存储运行该命令!?
我的故事板中有3个项目.1. viewController(A)连接到2.导航控制器和3. viewController(B)没有连接任何东西所有3个项目都在故事板中设置了恢复标识符.
viewController(B)是初始视图控制器.我在B中尝试获取附加A的导航控制器,但总是返回nil:
let storyBoard: UIStoryboard = UIStoryboard(name: "Main", bundle: nil)
let vc = storyBoard.instantiateViewControllerWithIdentifier("viewControllerA") as! ViewControllerA
print(vc.navigationController?) // always prints nil
Run Code Online (Sandbox Code Playgroud)
为什么!?
更新#1 我不能像视图控制器一样声明UINavigationController.我已经尝试将id为'myNavigationController'的navigationcontroller设置为storyboardID:
当故事板,我得到这个错误
let navigationController = storyBoard.instantiateViewControllerWithIdentifier("myNavigationController") as! UINavigationController
print(self.navigationController!) // fatal error: unexpectedly found nil while unwrapping an Optional value
Run Code Online (Sandbox Code Playgroud)
我也尝试在恢复标识符中设置id,它早先在实例化的行中被轰炸了
@ColdLogic,看看我在整个项目中搜索该标识符时得到的匹配:
我有两个相同的C#代码,可以远程连接到另一台服务器:一个来自控制台,另一个来自Web应用程序:
var mgr = ServerManager.OpenRemote(myServer)
Run Code Online (Sandbox Code Playgroud)
控制台一个正常工作.另一个失败,但有以下异常:
System.UnauthorizedAccessException的与此COM消息:{"检索COM类工厂远程组分与从机失败CLSID {2B72133B-3F5B-4602-8952-803546CE3344}由于以下错误:80070005"}
我已在两台服务器上禁用防火墙并重新启动它们.
有没有办法或工具可以帮助我了解每个连接如何发挥作用:服务器发送和接收的登录和访问权限是什么?
我的尝试没有被困在IIS日志和事件查看器中.
我试图让小提琴听,但它也没有找到任何东西.
angular ×2
c# ×2
swift ×2
typescript ×2
angularjs ×1
app-config ×1
azure ×1
azure-cli ×1
cloudkit ×1
css ×1
iis-7.5 ×1
ios ×1
nlog ×1
nspredicate ×1
winforms ×1