Example #1
0
        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));
        }
Example #3
0
        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));
        }
Example #4
0
        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));
        }
Example #5
0
        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));
        }
Example #6
0
        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));
        }
Example #7
0
        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));
        }
Example #8
0
        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);
        }
Example #9
0
        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);
            }
        }
Example #10
0
 public static EmployeeWithActivitiesIncludeModel Create(ApplicationUser user)
 {
     return(SimpleProjection.Compile().Invoke(user));
 }
Example #11
0
 public static ProjectGroupLookupModel Create(ProjectGroup projectGroup)
 {
     return(SimpleProjection.Compile().Invoke(projectGroup));
 }
Example #12
0
 public static ProjectMemberLookupModel Create(ApplicationUser user)
 {
     return(SimpleProjection.Compile().Invoke(user));
 }
Example #13
0
 public static ActivityListIncludeModel Create(ActivityList activityList)
 {
     return(SimpleProjection.Compile().Invoke(activityList));
 }
Example #14
0
 public static SprintLookupModel Create(Sprint sprint)
 {
     return(SimpleProjection.Compile().Invoke(sprint));
 }