- Modeling
- Entities
Additional Mutable Properties
To add mutable properties to the model, keep defining new facts.
Add them to the projection to get a complete picture of your entities.
[FactType("Blog.Site.Domain")]
public record SiteDomain(Site site, string value, SiteDomain[] prior) { }
Renderer.RenderTypes(typeof(SiteDomain), typeof(SiteName))
var siteDomain0 = await jinagaClient.Fact(new SiteDomain(site, "example.com", []));
jinagaClient.RenderFacts(siteDomain0, siteName2)
var sitesByUser = Given<User>.Match((user, facts) =>
from site in facts.OfType<Site>()
where site.creator == user
where !facts.Any<SiteDeleted>(
sd => sd.site == site &&
!facts.Any<SiteRestored>(sr => sr.deleted == sd))
select new
{
Site = site,
Names =
from name in facts.OfType<SiteName>()
where name.site == site
where !facts.Any<SiteName>(next => next.prior.Contains(name))
select name.value,
Domains =
from domain in facts.OfType<SiteDomain>()
where domain.site == site
where !facts.Any<SiteDomain>(next => next.prior.Contains(domain))
select domain.value
});
var sites = await jinagaClient.Query(sitesByUser, user);
var sitesViewModel = sites.Select(s => new
{
Name = s.Names.FirstOrDefault() ?? "New site",
Domain = s.Domains.FirstOrDefault() ?? ""
});
sitesViewModel
index | value |
---|
0 | { Name = My Journal, Domain = example.com }
|
Continue With
Hierarchy