Exemplo n.º 1
0
        internal T Key <T>(IAddition <IPrimaryKey <T> > keyedAddition)
        {
            var a = (Add)keyedAddition;

            if (!a.IsExecuted)
            {
                throw new TectureOrmFeatureException($"Cannot obtain primary key: addition of '{a.Entity}' did not happen yet");
            }

            T      result;
            string hash = Aux.IsHashRequired ? $"ORM_AdditionPK_{a.Order}" : string.Empty;

            if (Aux.IsEvaluationNeeded)
            {
                result = (T)(GetKey(a, GetKeyProperties <T>(a)).First());
            }
            else
            {
                result = Aux.Get <T>(hash, "ORM Addition PK retrieval");
            }

            if (Aux.IsTracingNeeded)
            {
                if (!Aux.IsEvaluationNeeded)
                {
                    Aux.Query(hash, "test data", "ORM Addition PK retrieval");
                }
                else
                {
                    Aux.Query(hash, result, "ORM Addition PK retrieval");
                }
            }

            return(result);
        }