Пример #1
0
        public void Convert()
        {
            var valTuple = ValueTupleConvert.Convert(typeof(ValueTuple <int, string, long>), new object[] { 1, "SmartSql", 2L });
            var typedVal = (ValueTuple <int, string, long>)valTuple;

            Assert.NotNull(valTuple);
        }
Пример #2
0
        public async Task <TResult> ToSingeAsync <TResult>(ExecutionContext executionContext)
        {
            var valueTupleType             = typeof(TResult);
            var resultGenericTypeArguments = valueTupleType.GenericTypeArguments;
            var resultItems = new object[resultGenericTypeArguments.Length];

            for (int i = 0; i < resultGenericTypeArguments.Length; i++)
            {
                var argType = resultGenericTypeArguments[i];
                var deser   = _deserializerFactory.Get(executionContext, argType);
                resultItems[i] = TypeDeserializer.Deserialize(argType, deser, executionContext);
                if (!await executionContext.DataReaderWrapper.NextResultAsync())
                {
                    break;
                }
            }
            return((TResult)ValueTupleConvert.Convert(valueTupleType, resultItems));
        }