English 中文(简体)
LINQ 到 SQL 继承 Pros 和 Cons
原标题:LINQ to SQL Inheritance Pros and Cons

我正在设计一个环绕 Linq2SQL 引擎的游戏。

除其它对象外,该游戏还有用户和 NPC (非玩耍字符) 。

用户和国家专利委员会的能力略有不同,但也有一些共同的特性,如健康或损害程度。

这些活动采用以下方法进行: lese攻击用户(用户攻击者、用户目标)

这里的问题是,NPC系统也可以攻击用户和其他NPC系统,用户也可以攻击NPC系统,所以我必须写出相当几种额外的方法和超载(例如, eve attackNpc(用户攻击器,Npc npc) )。

我可以使用 Linq2SQL 的继承特征来简化所有这一切, 使用 1 个通用表格生物, 而不是用户和 NPC 。 这样也可以让我使用一种通用的方法, < code> 避免攻击( 自然攻击者、 生物目标) < / code >, 而不是多种版本 。

另一方面,Linq2SQL的继承问题似乎大大增加了解决方案的总体复杂性。 每次我决定改变用户或NPC,我都需要考虑继承问题。此外,Linq2SQL的继承问题,Linq2SQL的用户和NPC的单独表格不够清晰,因为一切都被抛在一张桌子上。最后,我担心这种综合生物表的性能。

很难决定我是否应该或不应该在这里使用遗产,因为如果我选择一种次优的办法,今后就很难转而采用另一种办法。

我想听听专家对此的意见。

谢谢

问题回答

Each time I decide to make changes to Users or NPC s, I will need to consider the inheritance issues.

是的,但如果他们有很多的Common, 也是有益的, 因为您不需要做两次更改。 因此您没有使用遗产, 您需要考虑重复问题 。

Also, with inheritance in Linq2SQL I don t have that clarity of separate tables for Users and NPC s because everything is being dumped into one table.

您正在使用 Linq2SQL 来从数据库设计中提取摘要, 所以“ 谁在乎” 。 如果您有“ 类型” 字段, 如果您真的需要的话, 您仍然可以创建一个用户和 NPC < code> view

And finally, I m concerned regarding performance of such combined Creatures table.

假设你正在使用 Sql 服务器, 在你陷入麻烦之前 你需要大量的生物, 只要你注意正确的索引

简言之,我要继承遗产





相关问题
Manually implementing high performance algorithms in .NET

As a learning experience I recently tried implementing Quicksort with 3 way partitioning in C#. Apart from needing to add an extra range check on the left/right variables before the recursive call, ...

Anyone feel like passing it forward?

I m the only developer in my company, and am getting along well as an autodidact, but I know I m missing out on the education one gets from working with and having code reviewed by more senior devs. ...

How do I compare two decimals to 10 decimal places?

I m using decimal type (.net), and I want to see if two numbers are equal. But I only want to be accurate to 10 decimal places. For example take these three numbers. I want them all to be equal. 0....

Exception practices when creating a SynchronizationContext?

I m creating an STA version of the SynchronizationContext for use in Windows Workflow 4.0. I m wondering what to do about exceptions when Post-ing callbacks. The SynchronizationContext can be used ...

Show running instance in single instance application

I am building an application with C#. I managed to turn this into a single instance application by checking if the same process is already running. Process[] pname = Process.GetProcessesByName("...

How to combine DataTrigger and EventTrigger?

NOTE I have asked the related question (with an accepted answer): How to combine DataTrigger and Trigger? I think I need to combine an EventTrigger and a DataTrigger to achieve what I m after: when ...

热门标签