Ejemplo n.º 1
0
        public async Task <IEnumerable <dynamic> > ConvertAsync(MsSqlDbAttribute input, CancellationToken cancellationToken)
        {
            var context = _msSqlDbExtensionConfigProvider.CreateContext(input);

            var sqlSpec = new MsSqlSpec()
            {
                Parameters = input.SqlQueryParameters,
                Query      = input.SqlQuery
            };

            var list = new List <object>();

#if NETCOREAPP3_1
            var objects = context.MsSqlDbService.GetAsync(sqlSpec, cancellationToken);

            await foreach (var o in objects.WithCancellation(cancellationToken))
            {
                list.Add(o);
            }
#else
            var objects = await context.MsSqlDbService.GetAsync(sqlSpec, cancellationToken);

            list.AddRange(objects);
#endif
            return(list.AsEnumerable());
        }
Ejemplo n.º 2
0
        public Task <T> ConvertAsync(MsSqlDbAttribute input, CancellationToken cancellationToken)
        {
            var context = _msSqlDbExtensionConfigProvider.CreateContext(input);

            var sqlSpec = new MsSqlSpec()
            {
                Parameters = input.SqlQueryParameters,
                Query      = input.SqlQuery
            };

            return(context.MsSqlDbService.GetOne <T>(sqlSpec, cancellationToken));
        }