草庐IT

Property_value

全部标签

c# - EF4 代码优先 : how to add a relationship without adding a navigation property

我应该如何在不使用任何导航属性的情况下使用CodeFirst来定义关系?之前,我通过在关系的两端使用导航属性来定义一对多和多对多。并在数据库中创建适当的关系。这是类外观的精简版本(为简单起见,我已将多对多关系转换为一对多)。publicclassUser{publicstringUserId{get;set;}publicstringPasswordHash{get;set;}publicboolIsDisabled{get;set;}publicDateTimeAccessExpiryDate{get;set;}publicboolMustChangePassword{get;set

c# - 有没有理由拥有没有 setter/getter 的属性(property)?

我的经理问我使用带有setter而没有getter的属性是否是好的做法。publicclassPropertyWrapper{privateMyClass_field;publicMyClassProperty{set{_field=value;}}publicstringFirstProperty{get{return_field.FirstProperty;}}publicstringSecondProperty{get{return_field.SecondProperty;}}}他将使用其他属性来公开私有(private)字段中的属性,由该setter设置。我的建议是只使用私有

c# - 在 WPF 中获取 "<Property Name> was already registered by "<控件名称>"错误

我在WPF中有一个用户控件,它绑定(bind)到一个依赖属性。当我尝试编译应用程序时,出现“属性名称”已由“控件名称”注册的错误,设计器显示“无法创建“用户控件”的实例”错误。这是我的简单控件的样子:ExampleUserControl.xaml:ExampleUserControl.xaml.cs:publicpartialclassExampleUserControl:UserControl{publicDependencyPropertySomeStringValueProperty=DependencyProperty.Register("SomeStringValue",ty

c# - LINQ Order By Descending with Null Values on Bottom

这个问题在这里已经有了答案:LINQorderbynullcolumnwhereorderisascendingandnullsshouldbelast(10个答案)关闭8年前。我有这样的表达:troubletickets=db.ServiceTickets.Include(t=>t.Company).Include(t=>t.UserProfile);troubletickets.OrderByDescending(t=>t.UserProfile!=null?t.UserProfile.FirstName:"ZZZ");我必须检查UserProfile是否为null,因为如果不这样

c# - 内部 protected 属性(property)仍然可以从不同的程序集访问

我正在为有关辅助功能的初学者session设置一些演示代码,我发现我能够从派生类访问内部protected属性。我错过了什么?程序集1namespaceAccessibility{classProgram{staticvoidMain(string[]args){ExampleClassc=newExampleClass();c.Go();//c.Prop1=10;}}classExampleClass:DerivedClass{publicvoidGo(){this.Prop1=10;this.Prop2=10;//this.Prop3=10;//Doesn'twork//this.

c# - 找不到段 'Property' 的资源

当使用ADO.Net数据服务客户端通过调用LoadProperty刷新实体时:ctx.BeginLoadProperty(this,"Owner",(IAsyncResultar)=>...如果属性为null,它会在服务器上抛出一个错误Error:ExceptionThrown:System.Data.Services.DataServiceException:Resourcenotfoundforthesegment'Owner'.atSystem.Data.Services.RequestDescription.GetSingleResultFromEnumerable(Segme

c# - 具有 "has property X"约束的通用函数?

我有一个导出COM接口(interface)的第三方闭源应用程序,我通过Interop在我的C#.NET应用程序中使用它。此COM接口(interface)导出许多对象,这些对象都显示为System.Object,直到我将它们转换为适当的接口(interface)类型。我想为所有这些对象分配一个属性。因此:foreach(objectxinBigComInterface.Chickens){(xasChicken).attribute=value;}foreach(objectxinBigComInterface.Ducks){(xasDuck).attribute=value;}但是

c# - EF4.1 代码优先 : How to disable delete cascade for a relationship without navigation property in dependent entity

假设我有这两个非常基本的实体:publicclassParentEntity{publicintId;publicvirtualICollectionChildrens;}publicclassChildEntity{publicintId;publicintParentEntityId;//ForeignKeypublicvirtualParentEntityparent;//[NOTWANTED]}出于某些原因,我不希望ChildEntity保留对其父项的引用。我只希望它保留ParentEntityid但仅此而已。到目前为止,没问题,我只是删除了[NOTWANTED]行,一切都按预

c# - Entity Framework : Setting a Foreign Key Property

我们有一个大致如下所示的表格:CREATETABLELockers{UserIDintNOTNULLPRIMARYKEY(foreignkey),LockerStyleIDint(foreignkey),NameplateIDint(foreignkey)}所有键都与其他表相关,但由于应用程序的分布方式,我们更容易将ID作为参数传递。所以我们想这样做:Lockerl=newLocker{UserID=userID,LockerStyleID=lockerStyleID,NameplateID=nameplateID};entities.AddLocker(l);我们可以在LINQ-to

c# - "Value Does not fall in the expected range"ClickOnce部署

我已经使用了几个月的ClickOnce应用程序,但最近开始在部署最新版本时出现错误。在这个最新版本中,我添加了对我以前从未使用过的DLL的引用(FTD2XX_NET.dll如果相关),并怀疑这与问题有关,但我不知道如何解决它。正在部署的实际项目引用了另一个库项目,它引用了DLL(它引用了其他DLL,但已经工作了几个月而且它们没有改变)。正在关注thesethreads我尝试删除我的“本地设置/应用程序”文件夹并多次重启,以及重新创建项目并部署到不同的位置。该错误存在于多台机器上,所以我不怀疑它是用户配置文件损坏。这是我得到的完整错误:PLATFORMVERSIONINFOWindows