我已经基于现有数据库创建了一个实体框架模型.实体框架正在使用ADO.NET DbContext Generator.
我还创建了一个使用第一个项目的DLL的MVC3/Razor项目.当我单击"添加 - >控制器"选项并填写必填字段时,我收到一个恼人的错误:
Scaffolding GroupController...
EMR_MasterEntities already has a member called 'Groups'. Skipping...
Get-PrimaryKey : Cannot find primary key property for type 'CHS.CCC.DataModel.Group'. No properties appear to be primar
y keys.
At C:\Users\adriangilbert\Desktop\CHS.Monitor\packages\MvcScaffolding.1.0.6\tools\Controller\MvcScaffolding.Controller.
ps1:74 char:29
+ $primaryKey = Get-PrimaryKey <<<< $foundModelType.FullName -Project $Project -ErrorIfNotFound
+ CategoryInfo : NotSpecified: (:) [Get-PrimaryKey], Exception
+ FullyQualifiedErrorId : T4Scaffolding.Cmdlets.GetPrimaryKeyCmdlet
Run Code Online (Sandbox Code Playgroud)
为了解决这个问题,我需要转到Visual Studio生成的Groups.c并添加'using System.ComponentModel.DataAnnotations;' 然后将[Key]添加到Groups字段的声明中.但是这是生成的代码.如果我重新编译实体框架项目,我的更改当然会丢失.
所以 - 我的问题是:
我做错了什么导致Visual Studio无法弄清楚Key字段是什么,或者这只是Scaffolding Code的一个错误,它阻止它弄清楚Key是什么.
我应该提一下,这只能通过基于字符串的主键失败.如果该字段已被声明为整数,那么一切都完美无缺.
这是有问题的表格:
CREATE TABLE [dbo].[Groups](
[group_name] [varchar](45) NOT NULL,
[dbname] [varchar](45) NOT …Run Code Online (Sandbox Code Playgroud) primary-key entity-framework-4.1 asp.net-mvc-3 dbcontext asp.net-mvc-scaffolding
我正在查看System.ServiceModel.OperationContext
http://msdn.microsoft.com/en-us/library/system.servicemodel.operationcontext(v=vs.110).aspx
我试图理解之间的区别:
OperationContext.Current
OperationContext.InstanceContext
OperationContext.RequestContext
Run Code Online (Sandbox Code Playgroud)
在我的测试中,它们似乎是一样的.我错过了什么?
如何删除字符串中的每个第二个字符?
例如:
3030313535333635 -> 00155365
3030303336313435 -> 00036145
3032323437353530 -> 02247550
Run Code Online (Sandbox Code Playgroud)
字符串总是16个字符长,结果总是8个字符长 - 被删除的字符总是'3' - 不要问为什么然而 - 我没有想到这个疯狂的源数据.
在WinForms解决方案中,您有多个相同类型的控件.您需要为每个控件添加一个事件处理程序,并且在当前时间事件处理程序将执行相同的操作.你不希望他们在路上出现任何原因.
例如:
ScheduledPatientsGrid.ProcessGridKey += ScheduledPatientsGrid_ProcessGridKey;
RecentPatientsGrid.ProcessGridKey += RecentPatientsGrid_ProcessGridKey;
RecentPatientsGrid.ProcessGridKey += RecentPatientsGrid_ProcessGridKey;
...
private void ScheduledPatientsGrid_ProcessGridKey(object sender, KeyEventArgs e)
{
...
}
private void RecentPatientsGrid_ProcessGridKey(object sender, KeyEventArgs e)
{
...
}
private void PatientsGrid_ProcessGridKey(object sender, KeyEventArgs e)
{
...
}
Run Code Online (Sandbox Code Playgroud)
现在,如下所示在不同事件之间共享单个事件处理程序或使用上面显示的代码示例中的不同事件更好吗?
ScheduledPatientsGrid.ProcessGridKey += ProcessGridKey;
RecentPatientsGrid.ProcessGridKey += ProcessGridKey;
RecentPatientsGrid.ProcessGridKey += ProcessGridKey;
private void ProcessGridKey(object sender, KeyEventArgs e)
{
...
}
Run Code Online (Sandbox Code Playgroud)
在下一页中,Microsoft似乎建议共享更好,但是我注意到自.NET 2.0以来它们没有更新它(即:Visual Studio 2008)
http://msdn.microsoft.com/en-us/library/4ac48519%28v=vs.90%29.aspx
在这种情况下是否有指南提出最佳做法建议?
我一直在bash脚本中使用"set -x"来帮助我调试一些函数,它对我来说一直很好用
-x After expanding each simple command, for command, case command,
select command, or arithmetic for command, display the expanded
value of PS4, followed by the command and its expanded arguments or
associated word list.
Run Code Online (Sandbox Code Playgroud)
但是我想在离开这个功能之前能够清除它
例如:
#/bin bash
function somefunction()
{
set -x
# some code I'm debugging
# clear the set -x
set ????
}
somefunction
Run Code Online (Sandbox Code Playgroud) c# ×3
.net ×2
bash ×1
dbcontext ×1
linq ×1
linux ×1
performance ×1
primary-key ×1
wcf ×1
winforms ×1