internal void SetOneToManyEntity() { Type collection = PropertyInfo.PropertyType; Type foreignEntityType = collection.GetGenericArguments()[0]; OneToMany.Entity = OrmManager.GetEntity(foreignEntityType); }
static Repository() { Entity entity = OrmManager.GetEntity(typeof(T)); if (entity == null) { throw new TableNotFoundException(); } Entity = entity; }
internal static void SetConnection(Assembly assembly, string filename) { UriBuilder uri = new UriBuilder(assembly.CodeBase); string directory = Path.GetDirectoryName(Uri.UnescapeDataString(uri.Path)); directory = Directory.GetParent(Directory.GetParent(directory).ToString()).ToString(); StringBuilder stringBuilder = new StringBuilder() .Append(directory) .Append("\\") .Append(string.Format("{0}", filename)); directory = stringBuilder.ToString(); try { using (XmlReader reader = XmlReader.Create(directory)) { Connection currentConnection = null; while (reader.Read()) { if (reader.NodeType == XmlNodeType.Element) { switch (reader.LocalName) { case "MySqlConnection": currentConnection = GetMySqlConnection(reader); break; case "XmlConnection": currentConnection = GetXmlConnection(reader); break; case "Table": Entity entity = OrmManager.GetEntity(reader.GetAttribute("name")); entity.Connection = currentConnection; break; } } } } } catch (FileNotFoundException exc) { throw new ConfigurationException(directory); } catch (Exception exc) { throw new ConfigurationException(); } }
internal void SetManyToOneEntity() { ManyToOne.Entity = OrmManager.GetEntity(PropertyInfo.PropertyType); }