static void Main(string[] args) { MapperProvider.Instance.RegisterAssembly(Assembly.GetExecutingAssembly()); // allows us to create ADO.NET classes // without knowing the actual driver // and by just using the app/web.config var factory = new AppConfigConnectionFactory("DemoDb"); var connection = factory.Create(); var queries = new UserQueries(connection); var constraints = new QueryConstraints<User>() .SortBy(x => x.FirstName) .Page(2, 2); var result = queries.FindAll(constraints); foreach (var user in result.Items) { // Note that each user is not mapped until it's requested // as opposed to the entire collection being mapped first. Console.WriteLine(user.FirstName); } // and storage: var storage = new UserStorage(connection); var firstUser = storage.Load(1); Console.WriteLine(firstUser.FirstName); }
public IActionResult ResetGridState([FromBody] GridGetStateDto request) { var result = new OperationResponse <bool>(); var connectionFactory = new AppConfigConnectionFactory(_configuration.GetConnectionString("CosDB"), "System.Data.SqlClient"); var context = new AdoNetContext(connectionFactory); try { result.Data = _gridHandler.ResetGridState(request.UserName, request.GridKey, context); } catch (Exception e) { result.State = ResponseState.Error; result.Messages.Add("Error resetting grid state"); _logger.LogError(e, "Error resetting grid state"); } finally { context.Dispose(); } return(Json(result)); }
public static AdoNetContext GetContexto() { var factory = new AppConfigConnectionFactory("ModeloDeDados"); return(new AdoNetContext(factory)); }