| 4D v18entity.diff( ) | ||||||||||||||
| 
 | 
    4D v18
 entity.diff( ) 
         | |||||||||||||
| プロパティ名 | 型 | 詳細 | 
| attributeName | 文字列 | 属性名 | 
| value | 属性の型による | エンティティ内での属性の値 | 
| otherValue | 属性の型による | entityToCompare内の属性の値 | 
コレクションに含まれるのは異なる値を持っていた属性のみです。差異が見つからない場合、entity.diff( ) は空のコレクションを返します。
このメソッドは型がstorage あるいは relatedEntity であるプロパティに適用されます(dataClassAttribute.kind参照)。リレートされたエンティティが更新された場合(外部キーを意味します)、リレートされたエンティティの名前とそのプライマリーキー名がattributeName プロパティに返されます(value および otherValue はリレートされたエンティティ名については空になります)。
比較するどちらかのエンィティがNull である場合、エラーが生成されます。
 C_COLLECTION($diff1;$diff2)
 employee:=ds.Employee.query("ID=1001").first()
 $clone:=employee.clone()
 employee.firstName:="MARIE"
 employee.lastName:="SOPHIE"
 employee.salary:=500
 $diff1:=$clone.diff(employee) // 全ての差異が返されます
 $diff2:=$clone.diff(employee;New collection("firstName";"lastName"))
  // firstName と lastName についての差異のみが返されます$diff1:
[
    {
        "attributeName": "firstName",
        "value": "Natasha",
        "otherValue": "MARIE"
    },
    {
        "attributeName": "lastName",
        "value": "Locke",
        "otherValue": "SOPHIE"
    },
    {
        "attributeName": "salary",
        "value": 66600,
        "otherValue": 500
    }
]$diff2:
[
    {
        "attributeName": "firstName",
        "value": "Natasha",
        "otherValue": "MARIE"
    },
    {
        "attributeName": "lastName",
        "value": "Locke",
        "otherValue": "SOPHIE"
    }
] vCompareResult1:=New collection
 vCompareResult2:=New collection
 vCompareResult3:=New collection
 $attributesToInspect:=New collection
 
 $e1:=ds.Employee.get(636)
 $e2:=ds.Employee.get(636)
 
 $e1.firstName:=$e1.firstName+" update"
 $e1.lastName:=$e1.lastName+" update"
 
 $c:=ds.Company.get(117)
 $e1.employer:=$c
 $e2.salary:=100
 
 $attributesToInspect.push("firstName")
 $attributesToInspect.push("lastName")
 
 vCompareResult1:=$e1.diff($e2)
 vCompareResult2:=$e1.diff($e2;$attributesToInspect)
 vCompareResult3:=$e1.diff($e2;$e1.touchedAttributes())vCompareResult1 (全ての差異が返されている):
[
    {
        "attributeName": "firstName",
        "value": "Karla update",
        "otherValue": "Karla"
    },
    {
        "attributeName": "lastName",
        "value": "Marrero update",
        "otherValue": "Marrero"
    },
    {
        "attributeName": "salary",
        "value": 33500,
        "otherValue": 100
    },
    {
        "attributeName": "employerID",
        "value": 117,
        "otherValue": 118
    },
  {
        "attributeName": "employer",
        "value": "[object Entity]",// Company の Entity 117
        "otherValue": "[object Entity]"// Company の Entity 118
    }
]vCompareResult2 ($attributesToInspect についての差異のみ返される)
[
    {
        "attributeName": "firstName",
        "value": "Karla update",
        "otherValue": "Karla"
    },
    {
        "attributeName": "lastName",
        "value": "Marrero update",
        "otherValue": "Marrero"
    }
]vCompareResult3 ($e1 がtouch した属性のみが返される)
[
    {
        "attributeName": "firstName",
        "value": "Karla update",
        "otherValue": "Karla"
    },
    {
        "attributeName": "lastName",
        "value": "Marrero update",
        "otherValue": "Marrero"
    },
    {
        "attributeName": "employerID",
        "value": 117,
        "otherValue": 118
    },
     {
        "attributeName": "employer",
        "value": "[object Entity]",// Company の Entity 117
        "otherValue": "[object Entity]"// Company の Entity 118
    }
]
	プロダクト: 4D
	テーマ: ORDA - エンティティ
	
        
        
	
	
	
	
	
	
	
	
	
	ランゲージリファレンス ( 4D v18)
	
	
	
	
	
 コメントを追加
コメントを追加