Esempio n. 1
0
        public async Task <IEnumerable <GroupDTO> > GetGroupsPage(string filters, string userFilter, string orderBy, bool descending, int from, int to)
        {
            var a = _client.Cypher
                    .Match("(g:Group), (s:Student), (ow)-[:OWNER]-(g)")
                    .Where(userFilter);

            if (!string.IsNullOrEmpty(filters))
            {
                a = a.AndWhere(filters);
            }

            a = a.With("g, {Id: ID(ow), Student: ow} as st");

            ICypherFluentQuery <GroupDTO> ret = a.Return((g, st) => new GroupDTO
            {
                Id      = Return.As <int>("ID(g)"),
                Group   = Return.As <Group>("g"),
                Student = st.As <StudentDTO>()
            });

            if (descending)
            {
                ret = ret.OrderByDescending(orderBy);
            }
            else
            {
                ret = ret.OrderBy(orderBy);
            }

            return(await ret.Skip(from).Limit(to).ResultsAsync);
        }