public async Task <ImmutableList <TProjection> > Query <TFact, TProjection>( TFact start, Specification <TFact, TProjection> specification, CancellationToken cancellationToken = default) where TFact : class { if (start == null) { throw new ArgumentNullException(nameof(start)); } var graph = factManager.Serialize(start); var startReference = graph.Last; var pipeline = specification.Pipeline; if (pipeline.CanRunOnGraph) { var products = pipeline.Execute(startReference, graph); return(specification.Projection switch { SimpleProjection simple => products .Select(product => factManager.Deserialize <TProjection>( graph, product.GetElement(simple.Tag) )) .ToImmutableList(), _ => throw new NotImplementedException() });
/// <summary> /// Create an alias for a projection /// </summary> /// <param name="projection">the projection instance</param> /// <param name="alias">LambdaExpression returning an alias</param> /// <returns>return NHibernate.Criterion.IProjection</returns> public static IProjection As(this SimpleProjection projection, Expression <Func <object> > alias) { string aliasContainer = ExpressionProcessor.FindMemberExpression(alias.Body); return(projection.As(aliasContainer)); }
public static EmployeeWithActivitiesIncludeModel Create(ApplicationUser user, string searchValue, int number) { if (string.IsNullOrEmpty(searchValue)) { return(SimpleProjection.Compile().Invoke(user)); } return(Projection.Compile().Invoke(user, searchValue, number)); }
public static ProjectGroupLookupModel Create(ProjectGroup projectGroup, ICollection <ProjectStatus> filter) { if (filter == null || !filter.Any()) { return(SimpleProjection.Compile().Invoke(projectGroup)); } return(Projection.Compile().Invoke(projectGroup, filter)); }
public static ProjectMemberLookupModel Create(ApplicationUser user, ICollection <ActivityStatus> filter) { if (filter == null || !filter.Any()) { return(SimpleProjection.Compile().Invoke(user)); } return(Projection.Compile().Invoke(user, filter)); }
public static ActivityListIncludeModel Create(ActivityList activityList, string searchValue, int number) { if (string.IsNullOrEmpty(searchValue)) { return(SimpleProjection.Compile().Invoke(activityList)); } return(Projection.Compile().Invoke(activityList, searchValue, number)); }
public static SprintLookupModel Create(Sprint sprint, ICollection <ActivityStatus> filter) { if (filter == null || !filter.Any()) { return(SimpleProjection.Compile().Invoke(sprint)); } return(Projection.Compile().Invoke(sprint, filter)); }
private static ImmutableList <ProductAnchorProjection> DeserializeSimpleProjection( Emitter emitter, SimpleProjection simpleProjection, Type type, ImmutableList <Product> products, Product anchor, string collectionName) { var productProjections = products .Select(product => new ProductAnchorProjection( product, anchor, emitter.DeserializeToType(product.GetFactReference(simpleProjection.Tag), type), collectionName )) .ToImmutableList(); return(productProjections); }
private static void TestSimpleProjection() { IList <JObject> objects = new List <JObject>(); JObject obj = new JObject(); obj.Add("test", JToken.FromObject(5f)); objects.Add(obj); obj = new JObject(); obj.Add("test", JToken.FromObject(7f)); objects.Add(obj); obj = new JObject(); obj.Add("test", JToken.FromObject(100f)); objects.Add(obj); obj = new JObject(); obj.Add("test", JToken.FromObject(12f)); objects.Add(obj); obj = new JObject(); obj.Add("test", JToken.FromObject(15f)); objects.Add(obj); obj = new JObject(); obj.Add("test", JToken.FromObject(36f)); objects.Add(obj); var projection = new SimpleProjection <float>("test"); IList <float> intendedProjections = new List <float>() { 5f, 7f, 100f, 12f, 15f, 36f }; var itr = 0; foreach (var curObj in objects) { var value = projection.Project(curObj); Util.Assert(Math.Abs(value - intendedProjections[itr++]) <= 0.01); } }
public static EmployeeWithActivitiesIncludeModel Create(ApplicationUser user) { return(SimpleProjection.Compile().Invoke(user)); }
public static ProjectGroupLookupModel Create(ProjectGroup projectGroup) { return(SimpleProjection.Compile().Invoke(projectGroup)); }
public static ProjectMemberLookupModel Create(ApplicationUser user) { return(SimpleProjection.Compile().Invoke(user)); }
public static ActivityListIncludeModel Create(ActivityList activityList) { return(SimpleProjection.Compile().Invoke(activityList)); }
public static SprintLookupModel Create(Sprint sprint) { return(SimpleProjection.Compile().Invoke(sprint)); }