public void CreateSimpleViewTest2() { GXSelectArgs arg = GXSelectArgs.Select <Company>(q => new { q.Id, q.Name }); arg.Columns.Add <Country>(q => q.Name); arg.Joins.AddInnerJoin <Company, Country>(a => a.Country, b => b.Id); GXCreateViewArgs view = GXCreateViewArgs.Create <CountriesView>(arg); string expected = "Create View Countries AS SELECT Company.`Id`, Company.`Name`, Country.`CountryName` FROM Company INNER JOIN Country ON Company.`CountryID`=Country.`ID`"; string actual = view.ToString(); Assert.AreEqual(expected, actual); }
public void CreateSimpleViewTest() { GXSelectArgs arg2 = GXSelectArgs.Select <Company>(q => q.Id); arg2.Where.And <Company>(q => q.Name.Equals("Gurux")); GXSelectArgs arg = GXSelectArgs.Select <Country>(q => new { q.Id, q.Name }); arg.Where.And <Country>(q => !GXSql.Exists <Company, Country>(a => a.Country, b => b.Id, arg2)); GXCreateViewArgs view = GXCreateViewArgs.Create <CountriesView>(arg); string expected = "Create View Countries AS SELECT `ID`, `CountryName` FROM Country WHERE NOT EXISTS (SELECT `Id` FROM Company WHERE UPPER(Company.`Name`) LIKE('GURUX') AND Country.`ID` = Company.`CountryID`)"; string actual = view.ToString(); Assert.AreEqual(expected, actual); }