草庐IT

propertie

全部标签

c# - 如何修复 : The number of properties in the Dependent and Principal Roles in a relationship constraint must be identical?

我正在对SQLServer2012数据库使用EntityFramework4.3.1,并且我正在使用POCO方法。我收到以下错误,我想知道是否有人可以解释如何修复它:模型验证异常Oneormorevalidationerrorsweredetectedduringmodelgeneration:\tSystem.Data.Entity.Edm.EdmAssociationConstraint::ThenumberofpropertiesintheDependentandPrincipalRolesinarelationshipconstraintmustbeidentical.没有可用

c# - 代码优先迁移 : How to set default value for new property?

我正在使用EF6在我的数据库中存储report类的实例。数据库已包含数据。假设我想向report添加一个属性,publicclassreport{//...somepreviousproperties//...newproperty:publicstringnewProperty{get;set;}}现在,如果我转到包管理器控制台并执行add-migrationReport-added-newPropertyupdate-database我将在“/Migrations”文件夹中获取一个文件,将newProperty列添加到表中。这很好用。但是,在数据库中的旧条目上,newPropert

c# - 属性与字段 : Need help grasping the uses of Properties over Fields

首先,我已经通读了有关该主题的一系列帖子,但由于我对封装和字段修饰符(私有(private)、公共(public)等)的理解,我觉得自己没有掌握属性。我学到的C#的主要方面之一是通过使用封装在代码中保护数据的重要性。我“认为”我理解这是因为使用修饰符(私有(private)、公共(public)、内部、protected)的能力。然而,在了解了属性之后,我在理解C#中不仅属性用途,而且数据保护的整体重要性/能力(我理解为封装)方面都感到困惑。更具体地说,当我接触到C#中的属性时,我读到的所有内容都是您应该尽可能使用它们代替字段,因为:1)它们允许您在无法直接访问字段时更改数据类型。2)

c# - 什么是 HttpRequestMessage.Properties?

HttpRequestMessage.Properties的目的是什么??我想知道它是否为我的应用程序提供了一些有用的东西。 最佳答案 在WebApi中它包含一些特殊的标志:http://www.strathweb.com/2013/08/asp-net-web-api-2-and-httprequestcontext/例如,IncludeErrorDetail、IsLocal、ClientCertificate存储在字典中,但具有易于访问的属性。 关于c#-什么是HttpRequest

c# - 执行阅读器 : Connection property has not been initialized

ExecuteReader:Connectionpropertyhasnotbeeninitialized.我的代码是protectedvoidButton2_Click(objectsender,EventArgse){SqlConnectionconn=newSqlConnection("DataSource=Si-6\\SQLSERVER2005;InitialCatalog=rags;IntegratedSecurity=SSPI");SqlDataReaderrdr=null;try{//2.Opentheconnectionconn.Open();//3.Passtheco

C# 错误 : "An object reference is required for the non-static field, method, or property"

我有两个类,一个用于定义算法参数,另一个用于实现算法:1类(算法参数):usingSystem;usingSystem.Collections.Generic;usingSystem.Linq;usingSystem.Text;namespaceVM_Placement{publicstaticclassAlgorithmParameters{publicstaticintpop_size=100;publicstaticdoublecrossover_rate=0.7;publicstaticdoublemutation_rate=0.001;publicstaticintchrom

c# - WPF 错误 40 BindingExpression 路径错误 : property not found on 'object'

我因这个绑定(bind)错误而把头撞在table上。我已经检查了几个帖子中是否存在BindingExpression路径错误,但看不到任何适合我的情况。无论如何,我有一个名为IncrementingTextBox的自定义控件。每当用户“检查”其上方的CheckBox时,我都会尝试禁用它。我在CheckBoxIsChecked属性上有一个绑定(bind),它工作正常并且在它应该触发时触发。它在ConfigurationModel上正确设置了UseSensorLength属性。但是,IncrementingTextBoxIsEnabled属性上的绑定(bind)会导致BindingExpr

c# - Properties.Settings.Default 的数据保存在哪里?

在我的WPF应用程序中,我在解决方案资源管理器中单击Settings.settings并输入一个具有User范围的StringCollection变量:在我的app.config中,我看到它们保存在那里:onetwothreefourfivesixseven然后我运行我的应用程序并使用以下代码:StringCollectionpaths=Properties.Settings.Default.Paths;Properties.Settings.Default.Paths.Add("addedincode");Properties.Settings.Default.Save();fore

c# - 为什么 Property Set 会抛出 StackOverflow 异常?

我懂java,通常会使用getter/setter方法。我有兴趣使用以下代码在C#中执行此操作,但它会引发StackOverflow异常。我做错了什么?调用代码c.firstName="a";属性代码publicStringfirstName;{get{returnfirstName;}set{firstName=value;}} 最佳答案 这是因为您正在递归地调用该属性-在set中您再次设置该属性,它会一直无限直到您炸毁堆栈。您需要一个私有(private)支持字段来保存值,例如privatestringfirstName;pub

C#/WPF : PropertyChanged for all Properties in ViewModel?

我有这样一个类:publicclassPersonViewModel:ViewModelBase//HereistheINotifyPropertyChangedStuff{publicPersonViewModel(Personperson){PersonEntity=person;}publicPersonPersonEntity{get{returnPersonEntity.Name;}privateset{PersonEntity.Name=value;RaisePropertyChanged("PersonEntity");}publicstringName{get{retu