SenseNet / sn-client-dotnet

A .Net client for sensenet that makes it easy to use the REST API of the Content Repository.
https://www.sensenet.com/
GNU General Public License v2.0
7 stars 16 forks source link

SnLinq support for the Client.NET #139

Closed kavics closed 1 month ago

kavics commented 3 months ago

Create a LINQ provider for the Client.NET. Example codes:

  1. Get a user by part of the login name
    var user = repository.Content
    .OfType<User>()
    .Where(u => u.LoginName.Contains("john"))
    .FirstOrDefault();
  2. Get the latest 5 articles
    var articles = repository.Content
    .OfType<Article>()
    .Where(a=> a.InTree("/Root/Content/Articles"))
    .OrderByDescending(a => a.CreationDate)
    .Take(5)
    .ToArray();
  3. The new projection and auto expansion
    var users = repository.Content
    .EnableAutofilters()
    .CountOnly()
    .DisableLifespan()
    .Where(c => c.Id < 100 && c is User)
    .OfType<User>()
    .Select(u => Content.Create<User>(
        u.Id,
        u.Domain,
        u.LoginName,
        u.Email,
        u.Manager.Id,
        u.Manager.Type,
        u.Manager.Path,
        u.Manager.FullName,
        u.CreatedBy.Id,
        u.CreatedBy.Type,
        u.CreatedBy.Path,
        u.CreatedBy.FullName,
        u.ModifiedBy))
    .ToArray();