Пример #1
0
        ////////////////////////////////////////////////////////////////////////////////////////////////
        /*--------------------------------------------------------------------------------------------*/
        private static void AddVertex <T>(ICreateOperationBuilder pCreCtx, T pVertex,
                                          out IWeaverVarAlias <T> pAlias) where T : Vertex, new()
        {
            IWeaverQuery q = Weave.Inst.Graph.AddVertex(pVertex);

            q = WeaverQuery.StoreResultAsVar(pCreCtx.GetNextAliasName(), q, out pAlias);
            pCreCtx.AddQuery(q, true);
            pCreCtx.SetupLatestCommand();
        }
Пример #2
0
        ////////////////////////////////////////////////////////////////////////////////////////////////
        /*--------------------------------------------------------------------------------------------*/
        private static void FindDuplicate <T>(ICreateOperationBuilder pCreCtx,
                                              Expression <Func <T, object> > pProp, string pValue, string pErrPropName)
            where T : IVertex, new()
        {
            IWeaverVarAlias alias;

            IWeaverQuery q = Weave.Inst.Graph
                             .V.ExactIndex(pProp, pValue)
                             .ToQueryAsVar(pCreCtx.GetNextAliasName(), out alias);

            pCreCtx.AddQuery(q, true, alias.Name + "?0:1;");
            string cmdId = pCreCtx.SetupLatestCommand(false, true);

            pCreCtx.AddCheck(new DataResultCheck(cmdId, (dr, i) => {
                if (dr.ToIntAt(i, 0) != 1)
                {
                    throw new FabDuplicateFault(typeof(T), pErrPropName, pValue);
                }
            }));
        }
Пример #3
0
        /*--------------------------------------------------------------------------------------------*/
        private static IWeaverVarAlias <T> VerifyVertex <T>(ICreateOperationBuilder pCreCtx,
                                                            long pVertexId) where T : Vertex, new()
        {
            IWeaverVarAlias <T> alias;
            string var = pCreCtx.GetNextAliasName();

            IWeaverQuery q = Weave.Inst.Graph.V
                             .ExactIndex <T>(x => x.VertexId, pVertexId)
                             .ToQueryAsVar(var, out alias);

            pCreCtx.AddQuery(q, true, "if(" + var + "){" + var + "=" + var + ".next();1;}else{0;}");
            string cmdId = pCreCtx.SetupLatestCommand(false, true);

            pCreCtx.AddCheck(new DataResultCheck(cmdId, (dr, i) => {
                if (dr.ToIntAt(i, 0) != 1)
                {
                    throw new FabNotFoundFault(typeof(T), "Id=" + pVertexId + " // " + i + " / " + cmdId);
                }
            }));

            return(alias);
        }