我正在使用EF CTP 4.我有一个简单的控制台应用程序(用于测试目的),它使用EF将一些数据插入SQL数据库.
我在插入物品时遇到了问题
using(var context = GetContext())
{
BOB b = new BOB();
b.Id = 1;
context.Bobs.Add(b);
context.SaveChanges();
}
Run Code Online (Sandbox Code Playgroud)
它抛出错误:{"无法将值NULL插入列'Id',表'TestDB.dbo.BOB';列不允许空值.INSERT失败.\ r \n语句已终止."}
该表只有1个Id int NOT NULL字段,它是主键,不是自动递增的Id.
在创建DataContext时,我有这个配置,肯定会被触发.
protected override void OnModelCreating(ModelBuilder builder)
{
builder.Entity<BOB>().HasKey(b => b.Id);
builder.Entity<BOB>().MapSingleType().ToTable("BOB");
}
Run Code Online (Sandbox Code Playgroud)
我还预先填充了这个表,然后通过调试器能够通过监视加载这个BOB对象...所以我真的很难过,因为能够加载我的BOB显示一切都是正确的...但是插入一个新的崩溃...
好的,我在控制台应用程序中托管WCF服务.
所有绑定都以编程方式创建,因此没有配置设置.
我有一个工作服务,只要我使用HttpTransportBindingElement
但是一旦我使用HttpsTransportBindingElement
然后没有任何作用,该服务不会在浏览器中显示,客户端应用程序返回一个405 (Method Not Allowed) CommunicationException
我试过设置一个SecurityBindingElement
我的CustomBinding
但我不确定我应该使用哪个选项.
SecurityBindingElement.CreateCertificateOverTransportBindingElement()
SecurityBindingElement.CreateAnonymousForCertificateBindingElement()
等等
下面是创建主机的代码
baseAddress = new Uri(string.Format("{0}://{1}", strConnectionType, ConfigurationManager.AppSettings["baseAddress"]));
ServiceHost host = new ServiceHost(typeof(IMyService), baseAddress);
host.AddServiceEndpoint(typeof(MyService), binding, String.Empty);
ServiceMetadataBehavior smb = new ServiceMetadataBehavior();
smb.HttpsGetEnabled = certificate != null;
smb.HttpGetEnabled = certificate == null;
host.Description.Behaviors.Add(smb);
ServiceDebugBehavior sdb = host.Description.Behaviors.Find<ServiceDebugBehavior>();
if (sdb == null)
{
host.Description.Behaviors.Add(new ServiceDebugBehavior() { IncludeExceptionDetailInFaults = true });
}
else
{
if (!sdb.IncludeExceptionDetailInFaults)
{
sdb.IncludeExceptionDetailInFaults = true;
}
}
if …
Run Code Online (Sandbox Code Playgroud) 所以目前有一段看起来像这样的代码......
string name = GetValues(sequenceOfCodes, 0, IDtoMatch, 1)[0];
Run Code Online (Sandbox Code Playgroud)
我刚刚更新了以下行
string name = sequenceOfCodes
.Select(x => x[0])
.Where(x => x == IDtoMatch)
.FirstOrDefault();
Run Code Online (Sandbox Code Playgroud)
哪个应该有希望返回相同的东西.
sequenceOfCodes是a List<List<String>>
,IDtoMatch
也是a string
.
所以希望这一切看起来都很好.
但是当我去编译时,我得到一个奇怪的错误
The type 'System.Windows.Forms.ComboBox' is defined in an assembly
that is not referenced.
You must add a reference to assembly 'System.Windows.Forms, Version=4.0.0.0,
Culture=neutral, PublicKeyToken=b77a5c561934e089'
Run Code Online (Sandbox Code Playgroud)
当我把新添加的代码带走时,编译好并运行......那么为什么它只是因为我添加了lambda expression
它认为我需要引用System.Windows.Forms.ComboBox
?
只是声明这是一个控制台应用程序.不是 winforms应用程序.
----------- ----------更新
好吧,所以我发现其中一个引用确实引用了System.Windows.Forms,我真的很失望,因为这是核心代码,不应该有这样的依赖:(
但是我仍然想知道为什么错误之前没有出现,直到我添加了我的代码行.
要确认,如果我删除了我的代码,我可以关闭VS并重新启动并重建,一切都很好.如果我添加我的代码行并关闭并重新启动等.错误将在重建时重新出现.
对我来说非常奇怪的错误.
谢谢你们的帮助
所以我有一个使用MVC样式配置配置的图表...
@(Html.Kendo().Chart<DIMVC.ViewModel.CompanyProduction>(Model.CompanyProduction)
.Name("Chart")
.Title("Files sent")
.Legend(legend => legend
.Position(ChartLegendPosition.Bottom)
)
.ChartArea(chartArea => chartArea
.Background("transparent")
)
.SeriesDefaults(seriesDefaults =>
seriesDefaults.Line().Style(ChartLineStyle.Smooth)
)
.Series(series => {
series.Line(model => model.SentFiles).Name("Sent Files");
... { lots more series added here }
}
.CategoryAxis(axis => axis
.Categories(model => model.MonthDisplay)
.Labels(labels => labels.Rotation(-90))
)
.ValueAxis(axis => axis.Numeric()
.Labels(labels => labels.Format("{0:N0}"))
.MajorUnit(10000)
)
.Tooltip(tooltip => tooltip
.Visible(true)
.Format("{0:N0}")
)
.Events(e => e
.SeriesClick("onSeriesClick")
)
Run Code Online (Sandbox Code Playgroud)
)
我的页面上也有一个滑块.当滑块值改变时,我处理这个事件.
@(Html.Kendo().RangeSlider()
.Name("yearRange")
.Min(2000)
.Max(DateTime.Today.Year)
.SmallStep(1)
.LargeStep(5)
.Values(Model.MinYear, Model.MaxYear)
.Events(e => e.Change("yearRangeChange"))
)
Run Code Online (Sandbox Code Playgroud)
javascript方法
function …
Run Code Online (Sandbox Code Playgroud) 我目前正在我选择的 js 中显示选定的值。
如您所见,我的选择框并未呈现所有单词。我想在新行上看到文本值
我已经尝试过这段代码,但似乎没有任何反应
有人可以告诉我我缺少什么吗?
div#doctrine_doctrinecontent_attributes_topic_id_chosen {
display: inline;
}
Run Code Online (Sandbox Code Playgroud)
$('.chosen-select').chosen({
allow_single_deselect: true,
no_results_text: 'No results matched',
width: '100%',
});
Run Code Online (Sandbox Code Playgroud)