예제 #1
0
        public async Task <ExpressionValueResponse> GetExpressionValue(ExpressionValueRequest request)
        {
            var   entityType = _implementationsContainer.Reflector.GetType(request.EntityTypeName);
            var   keyType    = _implementationsContainer.Metadata[request.EntityTypeName].GetPrimaryKey().GetDataType().GetClrType();
            var   method     = _handlerInternal.GetType().GetMethod(nameof(EfCoreEntityHandlerInternal.GetExpressionValueInternal), BindingFlags.NonPublic | BindingFlags.Instance).MakeGenericMethod(entityType, keyType);
            var   awaitable  = method.Invoke(_handlerInternal, new object[] { request.Ids, request.Properties }) as Task;
            await awaitable;

            return(awaitable.GetType().GetProperty("Result").GetValue(awaitable) as ExpressionValueResponse);
        }
예제 #2
0
        private async Task <Dictionary <string, string> > GetTemplateValues(IEnumerable <string> expressions, int entityIdentifier, string entityTypeName)
        {
            var request = new ExpressionValueRequest
            {
                EntityTypeName = entityTypeName,
                Ids            = new int[] { entityIdentifier },
                Properties     = expressions.Select(e => new PropertyInfoModel
                {
                    Name = e
                }).ToArray()
            };
            var response = await _entityHandler.GetExpressionValue(request) as ExpressionValueResponse <int>;

            var result = new Dictionary <string, string>();

            foreach (var prop in response.PropertyValues)
            {
                result.Add(prop.Key, prop.Value.FirstOrDefault().Value?.ToString());
            }
            return(result);
        }