Example #1
0
        public void ArangoDoc_CrossJoin()
        {
            var db = DatabaseGenerator.Get();

            var query = db.Query()
                        .For(_ => new int[] { 2011, 2012, 2013 }
                             .For(year => new int[] { 1, 2, 3, 4 }
                                  .Select(quarter => new
            {
                y    = year,
                q    = quarter,
                nice = AQL.Concat(AQL.ToString(quarter), "/", AQL.ToString(year))
            })));

            var queryData = query.GetQueryData();

            Assert.Equal(queryData.Query.RemoveSpaces(), @"
for `year` in @P1
for `quarter` in @P2
return { 
    `y` : `year` , 
    `q` : `quarter` , 
    `nice` : concat( [ to_string( `quarter` ) , @P3 , to_string( `year` ) ] ) 
}
".RemoveSpaces());

            Assert.Equal(queryData.BindVars.Count, 3);
            Assert.Equal(JsonConvert.SerializeObject(queryData.BindVars[0].Value), "[2011,2012,2013]");
            Assert.Equal(JsonConvert.SerializeObject(queryData.BindVars[1].Value), "[1,2,3,4]");
            Assert.Equal(queryData.BindVars[2].Value, "/");
        }
        public void GroupByNewSingleSelectExpressionKey_SelectOnlyOneKey()
        {
            var db = DatabaseGenerator.Get();

            db.Setting.Linq.TranslateGroupByIntoName = identifier => identifier;

            var query = db.Query <Person>().GroupBy(x => new { cage = AQL.ToString(x.Age) }).Select(byAge => byAge.Key.cage);

            Assert.Equal(query.GetQueryData().Query.RemoveSpaces(), "for `x` in `Person` collect `cage` = to_string( `x`.`Age` ) into `byAge` return `cage`");

            db.Setting.Linq.TranslateGroupByIntoName = null;
        }
Example #3
0
        public void GroupBySingleSelectExpressionKey()
        {
            var db = DatabaseGenerator.Get();

            db.Setting.Linq.TranslateGroupByIntoName = identifier => identifier;

            var query = db.Query <Person>().GroupBy(x => AQL.ToString(x.Age)).Select(byAge => byAge.Key);

            Assert.Equal("for `x` in `Person` collect `CV1` = to_string( `x`.`Age` ) into `byAge` return `CV1`", query.GetQueryData().Query.RemoveSpaces());

            db.Setting.Linq.TranslateGroupByIntoName = null;
        }