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); }
public async Task <IEnumerable <StudentDTO> > GetStudentsPage(string filter, string userFilter, string orderBy, bool descending, int from, int to, int user) { var a = _client.Cypher .Match($"(s1:Student), (s2:Student)") .Where(userFilter); if (!string.IsNullOrEmpty(filter)) { a = a.AndWhere(filter); } ICypherFluentQuery <StudentDTO> ret = a.Return(() => new StudentDTO { Id = Return.As <int>("ID(s1)"), IsFriend = Return.As <bool>("exists((s1)-[:FRIEND]-(s2))"), Student = Return.As <Student>("s1") }); ret = ret.OrderBy(orderBy); return(await ret.Skip(from).Limit(to).ResultsAsync); }