예제 #1
0
        public static void IntoModelMetadata(ModelMetadata metadata, string dataSourceName, string key = "DataSource")
        {
            if (string.IsNullOrWhiteSpace(dataSourceName))
            {
                dataSourceName = metadata.PropertyName;
            }
            string dataSourceViewDataKey = DataSourceHelper.GetDataSourceViewDataKey(dataSourceName);

            metadata.AdditionalValues.Add(key, dataSourceViewDataKey);
        }
예제 #2
0
        public static string GetDataSourceViewDataKey <TModel, TProperty>(Expression <Func <TModel, TProperty> > expression)
        {
            string name = null;

            if (expression.Body.NodeType == ExpressionType.MemberAccess)
            {
                MemberExpression memberExpression = (MemberExpression)expression.Body;
                name = ((memberExpression.Member is System.Reflection.PropertyInfo) ? memberExpression.Member.Name : null);
            }
            return(DataSourceHelper.GetDataSourceViewDataKey(name));
        }