private void ParseEntity(XmlNode entityNode, string defaultNamespace, string defaultSchema, string defaultHint) { string type = this.GetTypeName(entityNode, "type", defaultNamespace); string table = this.GetTableName(entityNode, "table", defaultSchema); string keyMember = this.GetValue(entityNode, "keyMember"); KeyType keyType; // Default keyType is Auto switch (this.GetValue(entityNode, "keyType", "AUTO").ToUpper()) { case "GUID": keyType = KeyType.Guid; break; case "USER": keyType = KeyType.User; break; case "COMPOSITE": keyType = KeyType.Composite; break; case "NONE": keyType = KeyType.None; break; default: keyType = KeyType.Auto; break; } string sortOrder = this.GetValue(entityNode, "sortOrder"); // Paul Welter (http://www.LoreSoft.com) -- Removed special case for None keyType bool readOnly = true; // Default readOnly is False switch (this.GetValue(entityNode, "readOnly", "FALSE").ToUpper()) { case "TRUE": readOnly = true; break; default: readOnly = false; break; } bool changesOnly; // Default changesOnly is False switch (this.GetValue(entityNode, "changesOnly", "FALSE").ToUpper()) { case "TRUE": changesOnly = true; break; default: changesOnly = false; break; } bool autoTrack; // Default autoTrack is True switch (this.GetValue(entityNode, "autoTrack", "TRUE").ToUpper()) { case "FALSE": autoTrack = false; break; default: autoTrack = true; break; } string hint = this.GetValue(entityNode, "hint", defaultHint); string typeField = this.GetValue(entityNode, "typeField", null); string typeValue = this.GetValue(entityNode, "typeValue", null); EntityMap entity = new EntityMap( type, table, keyMember, keyType, sortOrder, readOnly, changesOnly, autoTrack, hint, typeField, typeValue); // Stored Procedures are Optional but Supported string insertSP = this.GetValue(entityNode, "insertSP"); string updateSP = this.GetValue(entityNode, "updateSP"); string deleteSP = this.GetValue(entityNode, "deleteSP"); entity.AddSProcs(insertSP, updateSP, deleteSP); foreach (XmlNode attributeNode in entityNode.SelectNodes("attribute")) { this.ParseAttribute(entity, attributeNode); } foreach (XmlNode attributeNode in entityNode.SelectNodes("lookup")) { this.ParseLookup(entity, attributeNode, defaultSchema); } foreach (XmlNode attributeNode in entityNode.SelectNodes("relation")) { this.ParseRelation(entity, attributeNode, defaultNamespace, defaultSchema); } #if DEBUG_MAPPER Debug.WriteLine("Entity = " + type + " : " + entity.FieldCount.ToString() + " Fields, " + entity.RelationCount.ToString() + " Relations"); #endif if (keyType != KeyType.None) { // Jeff Lanning ([email protected]): Added length check to prevent "Index Out Of Bounds" exception later during execution (which is very hard to debug). if (entity.KeyFields.Length != keyMember.Split(',').Length) { throw new MappingException("Number of key fields specified for entity '" + type + "' does not matched the number found."); } try { string keyField; foreach (FieldMap f in entity.KeyFields) { keyField = f.Field; } } catch (Exception exception) { throw new MappingException("Mapping: Entity keyMember missing from Attribute members - " + type, exception); } } this.entities.Add(type, entity); this.commands.Add(type, ProviderFactory.GetCommands(entity, this.provider)); string typeName = type.Substring(type.LastIndexOf(".") + 1); if (!this.helper.ContainsKey(typeName)) { this.helper.Add(typeName, type); } else { this.helper[typeName] = null; } }