Ejemplo n.º 1
0
		private string ProcessRelationShipName(CSharpConfig config, ItemRelationship relationShip, string defaultName)
		{
			if (config.DataBase.Rewrite == null)
				return defaultName;

			var rewrite = config.DataBase.Rewrite.FirstOrDefault(c =>
					c.SchemaPK == relationShip.ItemGroupPK
					&& c.TablePK == relationShip.ItemPK
					&& c.ColumnPK == relationShip.PropertyPK
					&& c.SchemaFK == relationShip.ItemGroupFK
					&& c.TableFK == relationShip.ItemFK
					&& c.ColumnFK == relationShip.PropertyFK);

			if (rewrite != null)
				return rewrite.CustonName;

			return defaultName;
		}
Ejemplo n.º 2
0
		private List<ItemRelationship> GetRelationships(SqlConnection cnx, string tabela, string schema)
		{
			List<ItemRelationship> result = new List<ItemRelationship>();

			SqlCommand cmd = new SqlCommand(SqlRelationship(tabela, schema), cnx);
			var reader = cmd.ExecuteReader();

			while (reader.Read())
			{
				var relationShip = new ItemRelationship
				{
					ItemGroupPK = reader["SchemaPK"].ToString(),
					ItemPK = reader["TablePK"].ToString(),
					PropertyPK = reader["ColumnPK"].ToString(),

					ItemGroupFK = reader["SchemaFK"].ToString(),
					ItemFK = reader["TableFK"].ToString(),
					PropertyFK = reader["ColumnFK"].ToString(),

					RelationshipType = reader["Type"].ToString() == "M" ? ItemRelationshipType.Many : ItemRelationshipType.Single,
					Nullable = reader["Nullable"].ToString() == "1"
				};

				result.Add(relationShip);
			}

			return result;
		}