protected List <DCType> CreateBussinessObjectsFromResponse <BOType, DCType>(MultiVariableResponse response)
            where BOType : IMappableBussinessObject
            where DCType : IPopulateFromBO, new()
        {
            List <DCType> createdBO = new List <DCType>();

            foreach (MultiParameterResult parameterGroup in response.OutputParameters)
            {
                if (parameterGroup.Direction == ParameterDirection.Out)
                {
                    //foreach (ParameterBase paramValue in parameterGroup.ParamValue)
                    //{
                    //    Type paramValueType = paramValue.GetType();
                    //    MiddlewareParameter<paramValueType.GetType()> convertedParameter = paramValue.ToMiddlewareParam();
                    //    convertedParameter.ParamValue
                    //    BOType availableBO = MappedBussinessObjectFactory.CreateFromParamers<BOType>();
                    //    DCType dc = new DCType();
                    //    dc.Populate(availableBO);
                    //    createdBO.Add(dc);
                    //}
                    MiddlewareParameter <List <MiddlewareParameter> > convertedParameter = (MiddlewareParameter <List <MiddlewareParameter> >)((MultiParameterResult)parameterGroup).ToMiddlewareParam();
                    BOType availableBO = MappedBussinessObjectFactory.CreateFromParamers <BOType>(convertedParameter.ParamValue);
                    DCType dc          = new DCType();
                    dc.Populate(availableBO);
                    createdBO.Add(dc);
                }
            }
            return(createdBO);
        }
        public TaskOntologyResponse GetTaskOntologies(byte[] token)
        {
            IRacoonResponse      executeResponse = QueryExecution.ExecuteQueryAllTypes(token, SprocNames.GetTaskOntologies, Enumerable.Empty <IConvertToMiddlewareParam>(), ParameterTypeEnum.String & ParameterTypeEnum.Multivalue);
            TaskOntologyResponse response        = new TaskOntologyResponse(executeResponse);

            if (!response.AuthorisationOK)
            {
                return(response);
            }
            MultiVariableResponse queryRes = executeResponse as MultiVariableResponse;

            if (queryRes == null)
            {
                response.Status = false;
                response.Error  = new InvalidCastException("Unexpected return type from query");
                return(response);
            }
            else
            {
                List <TaskOntologyDataContract> returnableTaskOntologyList = new List <TaskOntologyDataContract>();
                foreach (MultiParameterResult param in queryRes.OutputParameters)
                {
                    if (param.Direction == ParameterDirection.Out)
                    {
                        MiddlewareParameter <List <MiddlewareParameter> > convertedParameter = (MiddlewareParameter <List <MiddlewareParameter> >)param.ToMiddlewareParam();
                        TaskOntology             availableTaskOntology  = MappedBussinessObjectFactory.CreateFromParamers <TaskOntology>(convertedParameter.ParamValue);
                        TaskOntologyDataContract returnableTaskOntology = new TaskOntologyDataContract(availableTaskOntology);
                        returnableTaskOntologyList.Add(returnableTaskOntology);
                    }
                }
                if (returnableTaskOntologyList.Count > 0)
                {
                    response.TaskOntologies = returnableTaskOntologyList;
                }
            }

            return(response);
        }