哪一个是SQL Server中主键的最佳选择?
有一些示例代码:
例如
CREATE TABLE new_employees
(employeeId UNIQUEIDENTIFIER DEFAULT NEWID(),
fname VARCHAR(20) )
GO
INSERT INTO new_employees(fname) VALUES ('Karin')
GO
Run Code Online (Sandbox Code Playgroud)
例如
CREATE TABLE new_employees
(
employeeId int IDENTITY(1,1),
fname varchar (20)
);
INSERT new_employees
(fname)
VALUES
('Karin');
Run Code Online (Sandbox Code Playgroud)
[材料代码](或商业代码,材料的标识.例如客户标识符)
例如
CREATE TABLE new_employees(
[ClientId] [varchar](20) NOT NULL,
[fName] [varchar](20) NULL
)
INSERT new_employees
(ClientID, fname)
VALUES
('C0101000001',--customer identifier?e.g.'C0101000001' a user-defined code.
'Karin');
Run Code Online (Sandbox Code Playgroud)
请给我一些建议,从三种类型的标识列或其他选项中选择主键.
谢谢!
Opening repository: D:\testproject\DotNet.
Failed to push new glyph for D:\testproject\DotNet\DotNet.WinForms\DotNet.WinForm.User\DotNet.WinForm.User.csproj. Return code from SccGlyphChanged was -2147467263.
Failed to push new glyph for D:\testproject\DotNet\DotNet.WinForms\DotNet.WinForm.User\DotNet.WinForm.User.csproj. Return code from SccGlyphChanged was -2147467263.
Failed to push new glyph for D:\testproject\DotNet\DotNet.WinForms\DotNet.WinForm.User\DotNet.WinForm.User.csproj. Return code from SccGlyphChanged was -2147467263.
Undoing edit: D:\testproject\DotNet\DotNet.WinForms\DotNet.WinForm.Staff\DotNet.WinForm.Staff.csproj
Failed to push new glyph for D:\testproject\DotNet\DotNet.WinForms\DotNet.WinForm.User\DotNet.WinForm.User.csproj. Return code from SccGlyphChanged was -2147467263
Run Code Online (Sandbox Code Playgroud)
提交解决方案时,输出窗口显示错误消息.谁可以给我一个建议.
当我们想要为所有用户(说不同的语言)申请时,我们需要一种全球技术.
在C#中,我们使用ResourceManager如下:
using System;
using System.Reflection;
using System.Resources;
public class Example
{
public static void Main()
{
// Retrieve the resource.
ResourceManager rm = new ResourceManager("ExampleResources" ,
typeof(Example).Assembly);
string greeting = rm.GetString("Greeting");
Console.Write("Enter your name: ");
string name = Console.ReadLine();
Console.WriteLine("{0} {1}!", greeting, name);
}
}
// The example produces output similar to the following:
// Enter your name: John
// Hello John!
Run Code Online (Sandbox Code Playgroud)
程序集有两个或多个语言资源:
Assembly
| --Assembly.en-us.resx
| --Assembly.zh-cn.resx
然后我们通过更改线程cultureinfo来使用不同的资源来存档以更改资源.
如果应用程序有很多dll(汇编)文件.
我想为应用程序提供一个单点(一种语言的一个资源文件),
对我的想法有一个很好的解决方案吗?
在我更改View(例如,Winform或UserControl)Language以实现相应语言的不同UI之前.
有一个问题如何转义 - 括号 - 花括号 - 格式 - 字符串在网中,但没有描述原因?为什么使用{{或}}不使用\{或\}.
例如. string s = String.Format("{{ hello to all }}"); 为什么不在\{字符串中使用like string escape,例如: \b\n\t
**我想知道深层原因还是来自语言设计**
INotifyDataErrorInfo 内部只有 3 个内容:
\n\nHasErrors:一个只读布尔属性,用于判断对象作为一个整体是否存在任何验证错误;
\n GetErrors:返回给定属性的验证错误的方法;
\nErrorsChanged:当检测到新错误 \xe2\x80\x93 或缺少错误 \xe2\x80\x93 时必须引发的事件。您必须为每个属性引发此事件。
在演示项目中,我创建了一个表单,它显示名为 的对象的属性\xe2\x80\x98Person\xe2\x80\x99。以下是如何在绑定中启用 INotifyDataErrorInfo 验证:
<TextBox Text="{Binding Name,Mode=TwoWay,ValidatesOnNotifyDataErrors=True}"/>\nRun Code Online (Sandbox Code Playgroud)\n\n我们必须将该ValidatesOnNotifyDataErrors属性设置为true。
然后,绑定将自行注册绑定的 Person 的 ErrorsChanged 事件。每次为绑定属性引发此事件时,控件都会自行调整以显示错误。仅当 HasErrors 设置为 true 时才会执行此操作。
\n\n问题:
\n\nErrorsChanged event is raised for\n the binded property, the controls will dress itself to display an\n error?如果我绑定Address.Country,Person是否会为ErrorsChanged绑定的属性引发事件?Address.Country为什么?有没有办法让这个绑定也显示错误?
演示代码有一些问题.
var values = new List<int>() { 100, 110, 120 };
var funcs = new List<Func<int>>();
foreach(var v in values)
funcs.Add( ()=>v );
foreach(var f in funcs)
Console.WriteLine(f());
Run Code Online (Sandbox Code Playgroud)
大多数人认为它是100/110/120.实际上是120/120/120.
但是vs2015和.net 4.5.1的结果将输出 100/110/120 ,而不是 120/120/120 .
当我按如下方式测试代码时,for和之间存在一些差异foreach
var values = new List<int> {100, 110, 120};
var funcs = new List<Func<int>>();
foreach (var v in values)
funcs.Add(() =>
{
Console.WriteLine(v);
return v;
} );
foreach (var f in funcs)
Console.WriteLine(f());
//will throw exception
for (int i=0;i<values.Count;i++)
funcs.Add(() => …Run Code Online (Sandbox Code Playgroud) 在 Prism 应用程序中,我想使用验证。我在我的 ViewModel 中实现了 INotifyDataError 接口,但我发现第一次加载控件时不会触发验证解决方案。
然后我发现了同样的问题,比如' wpf Validation Binding not fire on First Load '
我找到了解决问题的解决方案WPF 在第一次加载数据上下文时不触发验证是:
<TextBox Grid.ColumnSpan="2" Grid.Row="1" x:Name="textBoxFolder" Margin="2,4">
<TextBox.Text>
<Binding Path="this.MovieFolder" UpdateSourceTrigger="PropertyChanged">
<Binding.ValidationRules>
<!-- Validation rule set to run when binding target is updated. -->
<Rules:MandatoryInputRule ValidatesOnTargetUpdated="True" />
</Binding.ValidationRules>
</Binding>
</TextBox.Text>
</TextBox>
Run Code Online (Sandbox Code Playgroud)
如您所见,这ValidatesOnTargetUpdated="True"是关键点,此属性将使 WPF 在第一次加载数据上下文时触发验证。
但我认为这是一个丑陋的解决方案。我需要Binding.ValidationRules为每个要验证的控件添加一个。
有没有好的办法解决问题。
c# ×5
mvvm ×2
validation ×2
wpf ×2
closures ×1
database ×1
for-loop ×1
foreach ×1
format ×1
formatting ×1
git ×1
lambda ×1
sql-server ×1
string ×1