Beispiel #1
0
        private System.Collections.Generic.List <string> addInParametersFrom <T>(DbCommand command, T input, params string[] parametersToAdd)
        {
            if (parametersToAdd == null || parametersToAdd.Length == 0)
            {
                throw new Exception("parametersToAdd is empty");
            }
            System.Collections.Generic.IEnumerable <System.Reflection.PropertyInfo> properties =
                from p in Utilities.GetProperties(input)
                where p.CanRead
                select p;

            System.Collections.Generic.List <string> addedParameters = new System.Collections.Generic.List <string>();
            System.Array.ForEach <string>(parametersToAdd, delegate(string parameter)
            {
                System.Reflection.PropertyInfo property = properties.FirstOrDefault((System.Reflection.PropertyInfo p) => p.Name.Equals(DatabaseUtilities.GetMatchingPropertyName(parameter), System.StringComparison.CurrentCultureIgnoreCase));
                if (property != null)
                {
                    this.addInParameterFrom <T>(command, input, parameter, property);
                    addedParameters.Add(parameter);
                }
            });
            return(addedParameters);
        }