public IntegrationTestComplexType() { driverMock = new Mock <IDatabaseDriver>(); driverMock.Setup(x => x.GetSqlType(It.IsAny <PropertyMapping>(), It.IsAny <bool>())).Returns("TEST"); driverMock.Setup(x => x.CreateSqlStringBuilder()).Returns(new SqlStringBuilder()); select = FluentBaseBuilder <TestComposed, FolkeTuple> .Select(driverMock.Object, new Mapper()); }
private IQueryableCommand <T> GetQuery(IDatabaseDriver driver, IMapper mapper) { if (query == null) { if (fetches == null) { query = FluentBaseBuilder <T, FolkeTuple <object> > .Select(driver, mapper).All().From().Where((x, y) => x.Key().Equals(y.Item0)); } else { var selectQuery = FluentBaseBuilder <T, FolkeTuple <object> > .Select(driver, mapper).All(); foreach (var fetch in fetches) { selectQuery.All(fetch); } var fromQuery = selectQuery.From(); foreach (var fetch in fetches) { fromQuery.LeftJoinOnId(fetch); } fromQuery.Where((x, y) => x.Key().Equals(y.Item0)); query = fromQuery; } } return(query); }
public TestFluentGenericQueryBuilder() { var mySqlDriver = new MySqlDriver(); var mapper = new Mapper(); fluentSelectBuilder = FluentBaseBuilder <FakeClass, FolkeTuple> .Select(mySqlDriver, mapper); queryBuilder = fluentSelectBuilder.QueryBuilder; }
public IQueryableCommand <T> Build(IFolkeConnection connection) { if (query == null) { var select = FluentBaseBuilder <T, FolkeTuple> .Select(connection.Driver, connection.Mapper); query = prepare.Invoke(select); } return(query.Build(connection)); }
/// <summary> /// Select all the fields from the T type and the properties in parameter /// </summary> /// <typeparam name="T">The type to select on</typeparam> /// <param name="fetches">The other tables to select (using a left join)</param> /// <returns></returns> public IFromResult <T, FolkeTuple> SelectAllFrom <T>(params Expression <Func <T, object> >[] fetches) where T : class, new() { var query = FluentBaseBuilder <T, FolkeTuple> .Select(new BaseQueryBuilder(this, typeof(T))); var all = query.All(); foreach (var fetch in fetches) { query.All(fetch); } var fromQuery = all.From(); foreach (var fetch in fetches) { fromQuery.LeftJoinOnId(fetch); } return(fromQuery); }
public void SelectAllFrom_LimitWithParameter_List() { // Arrange for (var i = 0; i < 10; i++) { var newPoco = new TestPoco { Name = "Name" + i }; connection.Save(newPoco); } // Act var results = FluentBaseBuilder <TestPoco, FolkeTuple <int> > .Select(connection.Driver, connection.Mapper).All() .From() .OrderBy(x => x.Name) .Limit((x, y) => y.Item0, 5).Build(connection, 5).ToList(); // Assert Assert.Equal(5, results.Count); Assert.Equal("Name5", results[0].Name); }
public ISelectResult <T, TParameters> Select <T, TParameters>() where T : class, new() { return(FluentBaseBuilder <T, TParameters> .Select(new BaseQueryBuilder(this, typeof(T), typeof(TParameters)))); }
public ISelectResult <T, FolkeTuple> Select <T>() where T : class, new() { return(FluentBaseBuilder <T, FolkeTuple> .Select(new BaseQueryBuilder(this, typeof(T)))); }
public IntegrationTest() { driverMock = new Mock <IDatabaseDriver>(); select = FluentBaseBuilder <TestLinkTable, FolkeTuple> .Select(driverMock.Object, mapper); }
public void LeftJoin_OnItemsWithReferenceEqualsMethod() { var selectTuple = FluentBaseBuilder <FolkeTuple <TestLinkTable, TestOtherPoco>, FolkeTuple> .Select(driverMock.Object, mapper); selectTuple.All(x => x.Item0).From(x => x.Item0).LeftJoin(x => x.Item1).On(x => x.Item0.User.Equals(x.Item1)); }
public void LeftJoin_OnItemsSubWithId() { var selectTuple = FluentBaseBuilder <FolkeTuple <TestLinkTable, TestPoco>, FolkeTuple> .Select(driverMock.Object, mapper); selectTuple.All(x => x.Item0).From(x => x.Item0).LeftJoin(x => x.Item1).On(x => x.Item0.User.Id.Equals(x.Item1.Id)); }