2016-10-26 2 views

답변

0

당신은 내가 참조 필드를 추가 찾으의 문서 을 읽어야합니다, 당신은 당신이 참조 할 필요가 사용자 n은 당신의 분야에 대한 표현이

node.Addreferences("User", user1); 

사용자 1 인 하나의 노드와 같은 어떤 것을 사용해야

1

Sensenet의 모든 내용 (데이터)은 binary tree으로 구성되며 Node은 해당 내용 유형 정의 (CTD)에 지정된 특정 Content 개체를 나타냅니다. 노드가 다른 노드를 참조 할 때 (즉, 트리의 다른 위치를 가리키는 경우) 두 가지 유형 중 하나 일 수 있습니다.

  1. 이 노드에 어느 시점하거나
  2. CTD에 지정된 그것은하는 특정 형식으로 제한 될 수있다.

참조를 올바르게 지정했지만 오류가 발생하면 CTD의 유형 제약 조건을 위반하는 것일 수 있습니다. 아래 예를 참조하십시오.

CTD (부분) 특정 타입의 기준 노드 위에서 정의 된 분류 기준에 노드를 할당

<ContentType name="Agent" parentType="GenericContent" handler="Code.ContentHandlers.Agent" xmlns="http://schemas.sensenet.com/SenseNet/ContentRepository/ContentTypeDefinition"> 
    <DisplayName>Agent</DisplayName> 
    <Icon>Content</Icon> 
    <Fields> 

    <Field name="Category" type="Reference"> 
     <DisplayName>Agent Category</DisplayName> 
     <Description></Description> 
     <Configuration> 
     <AllowedTypes> 
      <Type>AgentCategory</Type> 
     </AllowedTypes> 
     <VisibleBrowse>Show</VisibleBrowse> 
     </Configuration> 
    </Field> 

    </Fields> 
</ContentType> 

예 C# 코드 용.

var path = "/Root/PathToAgentCategory"; 
var agentCat = Node.LoadNode(path) as AgentCategory; 
myAgentNode.Category = agentCat;  // Syntax if you have a ContentHandler 
myAgentNode["Category"] = agentCat; // Syntax for the GenericContent ContentHandler