Tag: 基地

inheritanceLinq to SQL类并转换linq查询的结果

我正在编写一个应用程序,我们需要将基本实体扩展为许多不同的东西(例如员工,车辆等)。 设计是这样的,即存在实体表和具有类型特定值的第二表,例如,雇员将具有ID号但车辆将具有注册号。 我从数据上下文中生成的类实体inheritance,但在我的存储库中进行转换时遇到问题。 这样做的正确方法是什么? public class cAccountEmployee : cAccountEntity { public string id_number { get { try { return this.cAccountEntityValues.Single(e => e.type == 1).value; } catch (Exception) { return “”; } } set { try { this.cAccountEntityValues.Single(e => e.type == 1).value = value; } catch (Exception) { this.cAccountEntityValues.Add(new cAccountEntityValue() { accountentity_id = this.id, cAccountEntity = […]

C# – 什么时候打电话给base.OnSomething?

我正在使用Windows.Forms并且必须inheritance一些控件来提供自定义行为。 这种inheritance显然会导致方法覆盖。 所以,这里有一个问题 – 在哪种情况下调用base.OnSomething(…)的顺序可以真正影响程序的可见行为? protected override OnRetrieveVirtualItem(RetrieveVirtualItemEventArgs e) { // base.OnRetrieveVirtualItem(e); – Could this potentially break something? // Perform your custom method. // … base.OnRetrieveVirtualItem(e); // Is this always “correct”? } 据我所知,当重写与绘画相关的方法( OnDrawItem, … )时,这个顺序很重要,但我想还有其他一些方法可以在腿上拍摄自己,因为Windows.Forms会做很多事情。非托管代码调用可能的副作用。 那么,什么时候可能重要? 在这些情况下,选择正确的位置来调用base方法有哪些经验法则?