circular-reference

Circular reference in domain model using c# struct

不羁岁月 提交于 2019-12-08 01:52:44
问题 What happens when there is a circular reference between two structs? How does memory allocation work for the example below or would it yield and error? public struct MultipleChoiceQuestion { public IEnumerable<Option> Options; } public struct Option { public MultipleChoiceQuestion Question; } 回答1: The Options field in MultipleChoiceQuestion is just a reference here, which will be null by default. The Question field in Option is a value of type MultipleChoiceQuestion which will have its

How can I get all parents' parents as columns for child object in circularly referenced table?

可紊 提交于 2019-12-07 17:47:06
问题 I have a table with columns like entityID, entityName, parentID How can I write a query to return all the levels of parents for an entity as to return something like childentityname, parentlevel1name, parentlevel2name, parentLevel3name and so on I am not a SQL ninja by any means. Is this possible? If so, how? I'm using Microsoft SQL Server DB. 回答1: A recursive CTE is what you need look here (EDIT: Only in SQL SERVER 2005+) Something along the lines of: WITH recurse_cte (entityID,entityName,

Circular references between two classes

筅森魡賤 提交于 2019-12-07 04:56:58
问题 I know this must be a n00b question, but I have to implement a mockup client-server sequential interaction application, and because the number of client-server calls varies, I cannot just iterate the steps in an external function, always fetching data from the client and then forwarding it to the server and vice-versa, so I need to make my Server and Client classes be aware of each other so that they can call their public methods between themselves. One approach would be to design both as

Reason for circular references with classes?

ε祈祈猫儿з 提交于 2019-12-07 04:29:21
问题 I'm aware of circular references (class a holds class b and class b holds class a). But since I haven't programmed enough, it's hard for me to find reasons to use them. I was wondering if people could give me some nice examples and possibly explain good reasons for using them. For example, right now I'm looking at 2D source code tutorials and the user created a Creature and a CreatureAi class that reference each other. For what reason? I don't know yet, that's why I'm looking for examples and

How can I pass `this` to a constructor without circular references (or losing type) in c++?

|▌冷眼眸甩不掉的悲伤 提交于 2019-12-06 21:46:37
EDIT: this has been marked as a duplicate. I believe there is a distinction between Q: what can I use to solve my problem, A: this thing ~and~ Q: what is this thing? A: big huge in depth answer. I'm not sure what the official ruling on this is though. I have two classes which both need to know about each other // Creator.h #pragma once #include "Creation.h" class Creator { Creator() { myThing = new Creation(*this); } int age = 42; Creation myThing*; } . // Creation.h #pragma once #include "Creator.h" class Creation { Creation(Creator &whoMadeMe) { std::cout << whoMadeMe.age; } } The issue is

Circular reference in domain model using c# struct

烂漫一生 提交于 2019-12-06 12:01:10
What happens when there is a circular reference between two structs? How does memory allocation work for the example below or would it yield and error? public struct MultipleChoiceQuestion { public IEnumerable<Option> Options; } public struct Option { public MultipleChoiceQuestion Question; } The Options field in MultipleChoiceQuestion is just a reference here, which will be null by default. The Question field in Option is a value of type MultipleChoiceQuestion which will have its default value by default. There's no problem here (other than a questionable design in more ways than one). A

Injecting EntityManager-dependend service into Listener

六眼飞鱼酱① 提交于 2019-12-06 06:52:54
问题 I am trying to inject one of my services into an EntityListener in order to call some application specific behaviour when an entity gets updated. My Logger service, used to store events in a LogEntry entity in my database: class Logger { /** * @var EntityManager $manager The doctrine2 manager */ protected $manager; //... } The listener: class EntityListener { public function __construct(Logger $logger) { $this->logger = $logger; // ... } } And the service definitions in my service.yml :

Copying Excel's Circular Reference formula in PHP

让人想犯罪 __ 提交于 2019-12-06 05:55:54
I am trying to copy an Excel's Circular Reference formula in PHP. In Excel I have: A19 = A25-A22 (result: 8771.65) A22 = A19*14.1% (result: 1236.80) A25 = 10000 But, it does not give me correct result when i try to compute it in PHP: $Tax = 0; $Gross = 0; $Net_Amount = 10000; $Gross = $Net_Amount - $Tax; $Tax = $Gross * (14.1/100); Any idea on how to do this in PHP? By default, Excel will report a warning when you have a circular reference. The exception is if you have told it to handle circular references up to a predefined (you define how many) number of iterations. The way to do the latter

Defining circular references using zope.schema

给你一囗甜甜゛ 提交于 2019-12-06 04:07:14
I'm trying to do the following, define two classes whose instances mutually reference one another, like Users and Groups in the following exemple. A User can belong to several groups and a Group can contains several users. The actual data is stored in a database and there it is a simple matter of many-to-many relationship using foreign keys. No problem at all. Afterward the data is loaded through an ORM and stored in instances of python objects. Still no problem at all as the ORM used (SQLAlchemy) manage backrefs. Now I want to check that the python objects comply to some interface using zope

Resolving Circular References for Objects Implementing ISerializable

为君一笑 提交于 2019-12-05 22:02:36
I'm writing my own IFormatter implementation and I cannot think of a way to resolve circular references between two types that both implement ISerializable. Here's the usual pattern: [Serializable] class Foo : ISerializable { private Bar m_bar; public Foo(Bar bar) { m_bar = bar; m_bar.Foo = this; } public Bar Bar { get { return m_bar; } } protected Foo(SerializationInfo info, StreamingContext context) { m_bar = (Bar)info.GetValue("1", typeof(Bar)); } public void GetObjectData(SerializationInfo info, StreamingContext context) { info.AddValue("1", m_bar); } } [Serializable] class Bar :