Massive.DynamicModel.CreateFrom C# (CSharp) Method

CreateFrom() public method

Creates a new Expando from a Form POST - white listed against the columns in the DB
public CreateFrom ( NameValueCollection coll ) : dynamic
coll NameValueCollection
return dynamic
        public dynamic CreateFrom(NameValueCollection coll)
        {
            dynamic result = new ExpandoObject();
            var dc = (IDictionary<string, object>)result;
            var schema = Schema;
            //loop the collection, setting only what's in the Schema
            foreach (var item in coll.Keys) {
                var exists = schema.Any(x => x.COLUMN_NAME.ToLower() == item.ToString().ToLower());
                if (exists) {
                    var key = item.ToString();
                    var val = coll[key];
                    dc.Add(key, val);
                }
            }
            return result;
        }