コード例 #1
0
ファイル: EtagIssue.cs プロジェクト: xinix00/ravendb
        public IEnumerable <ScriptedPatchCommandData> Establish(UserProfile user, ManagerOf managerOf,
                                                                OrganizationProfile organization, HasManager hasManager)
        {
            const string patchScript = "var _this = this;" +
                                       "function addRelation(clrType, relation, thisArg) {" +
                                       "   (thisArg || _this).Relations.push(_.extend({ '$type': clrType }, relation));" +
                                       "}" + "addRelation(relationClrType, relation);";

            yield return(new ScriptedPatchCommandData
            {
                Key = user.Id,
                Patch = new ScriptedPatchRequest
                {
                    Script = patchScript,
                    Values = new Dictionary <string, object>
                    {
                        { "relation", managerOf },
                        { "relationClrType", ClrType(managerOf.GetType()) }
                    }
                }
            });

            yield return(new ScriptedPatchCommandData
            {
                Key = organization.Id,
                Patch = new ScriptedPatchRequest
                {
                    Script = patchScript,
                    Values = new Dictionary <string, object>
                    {
                        { "relation", hasManager },
                        { "relationClrType", ClrType(hasManager.GetType()) }
                    }
                }
            });
        }
コード例 #2
0
ファイル: EtagIssue.cs プロジェクト: rstonkus/ravendb
        private IEnumerable <PatchCommandData> Establish(UserProfile user, ManagerOf managerOf,
                                                         OrganizationProfile organization, HasManager hasManager)
        {
            const string patchScript = "var _this = this;" +
                                       "function addRelation(clrType, relation, thisArg) {" +
                                       " relation['$type'] = clrType; " +
                                       "   (thisArg || _this).Relations.push(relation);" +
                                       "}" + "addRelation(args.relationClrType, args.relation);";

            yield return(new PatchCommandData(user.Id, null, new PatchRequest
            {
                Script = patchScript,
                Values = new Dictionary <string, object>
                {
                    { "relation", managerOf },
                    { "relationClrType", ClrType(managerOf.GetType()) }
                }
            }, null));

            yield return(new PatchCommandData(organization.Id, null, new PatchRequest
            {
                Script = patchScript,
                Values = new Dictionary <string, object>
                {
                    { "relation", hasManager },
                    { "relationClrType", ClrType(hasManager.GetType()) }
                }
            }, null));
        }