コード例 #1
0
        public Uri GetEntityApiUri(IPrimaryKey entity)
        {
            if (_templates == null)
            {
                lock (_lock)
                {
                    if (_templates == null)
                    {
                        _templates = CompileUrls();
                    }
                }
            }

            var testedType = GetMatchingType(entity.GetType());

            if (testedType == null)
            {
                return(null);
            }

            return(new UriBuilder(GetUrlBase())
            {
                Path = GetPath(testedType, entity)
            }.Uri);
        }
コード例 #2
0
        /// <summary>
        /// Obtains set of properties participating primary key of the entity
        /// </summary>
        /// <param name="pk">Entity with primary key</param>
        /// <returns>Set of properties participating primary key</returns>
        public static PropertyInfo[] KeyProperties(this IPrimaryKey pk)
        {
            var t = pk.GetType().GetProperty(nameof(IPrimaryKey <int> .PrimaryKey), BindingFlags.Public | BindingFlags.Instance);

            var keyProps = t.GetValue(pk);

            var extr = FromTuple <LambdaExpression>(keyProps).Select(x => x.AsPropertyExpression());

            return(extr.ToArray());
        }