Пример #1
0
        public async Task <IActionResult> Read()
        {
            var user = _services.ReadSingle <User>(a => a.Id == Guid.Parse("32feb0dd-6182-4dc0-9ad6-b147b6fb0cbb"));

            Console.WriteLine("--- user ---");
            Console.WriteLine(user);

            var users = await _services.ReadManyNoTracked <User>().ToListAsync();

            Console.WriteLine("--- users ---");
            Console.WriteLine(JsonSerializer.Serialize(users));

            var usersDto = await _services.ProjectFromEntityToDto <User, UserDto>(a => a).ToListAsync();

            Console.WriteLine($"--- {nameof(usersDto)} ---");
            Console.WriteLine(JsonSerializer.Serialize(usersDto));

            var userDto = await _services.ProjectFromEntityToDto <User, UserDto>(a => a.Where(b => b.Id == Guid.Parse("32feb0dd-6182-4dc0-9ad6-b147b6fb0cbb"))).FirstOrDefaultAsync();

            Console.WriteLine($"--- {nameof(userDto)} ---");
            Console.WriteLine(JsonSerializer.Serialize(userDto));

            return(Ok());
        }