internal bool Load(IEnumerable <WSTableSource> role_sources) { if (!Fields.Any()) { return(false); } else { foreach (WSEntityFieldSchema schema in Fields.OfType <WSEntityFieldSchema>()) { Type eType = schema.param.DataType.GetEntityType(); schema.SOURCE = role_sources.FirstOrDefault(x => x.ReturnType == eType); } List <string> illegalFields = Fields.OfType <WSEntityFieldSchema>().Where(x => x.SOURCE == null).Select(x => x.param.WSColumnRef.NAME).ToList(); if (illegalFields != null && illegalFields.Any()) { foreach (string field in illegalFields) { WSMemberSchema schema = Fields.FirstOrDefault(f => ((WSFieldSchema)f).param.WSColumnRef.NAME.Equals(field)); if (schema != null) { Fields.Remove(schema); } } } return(Fields.Any()); } }
private bool saveFieldSchema(WSMemberSchema field, bool replace, ref WSFieldFilters filters) { if (field != null) { Func <WSMemberSchema, bool> func = x => x is WSFieldSchema && ((WSFieldSchema)x).param.Match(field.Name); if (!filters.Any(func)) { filters.Add(field); } else { if (replace) { /* TODO@ANDVO : 2016-03-08 : combine redundant field's options somehow,... (when field used more than once in schema) * fx.: 'userid:{less:10}&schema={user:[*,{userid:{more:1}}]}' * note: ofcourse we can combine them like: 'schema={user:[*,{userid:{less:10,more:1}}]}', * but what if there will be need for option's separation as : AND <-> OR? */ filters[filters.IndexOf(filters.FirstOrDefault(func))] = field; } } return(true); } return(false); }