public static List<SourceEntity> QueryTargetEntitiesCriteria(Criteria criteria)
        {
            List<SourceEntity> retVal = new List<SourceEntity>();
            // Turn criteria into SQL Query

            using (aConn = new SqlConnection(aConnStr)) {
                aConn.Open();
                using (IDbCommand dbcmd = aConn.CreateCommand()) {
                    string sql ="SELECT Entity_ID, Entity_ShortDesc FROM ent.vwEntity WHERE Entity_Type_ID = "+criteria.targetEntityType+" AND Source_System_ID= "+criteria.targetSystem;
                    dbcmd.CommandText = sql;
                    using (IDataReader reader = dbcmd.ExecuteReader()) {

                        while(reader.Read()) {

                            int anID = Int16.Parse(reader["Entity_ID"].ToString());
                            string aName = (string) reader["Entity_ShortDesc"].ToString();

                            retVal.Add(new SourceEntity(anID,Int32.Parse (criteria.targetSystem),Int32.Parse(criteria.targetEntityType),aName));
                        }
                    }
                }
            }
            return retVal;
        }
        public static List<EntityRelationship> QueryRelationships(Criteria criteria)
        {
            List<EntityRelationship> retVal = new List<EntityRelationship>();

            using (aConn = new SqlConnection(aConnStr)) {
                aConn.Open();
                using (IDbCommand dbcmd = aConn.CreateCommand()) {
                    string sql ="SELECT Parent_Entity_ID srcID, Child_Entity_ID tarID,ENTITY_RELATIONSHIP_TYPE_ID relType,ENTITY_RELATIONSHIP_TYPE_SHORTDESC relDesc FROM ent.vwACTIVERELATIONSHIPS";
                    sql += " WHERE ((CHILD_SOURCE_SYSTEM_ID = "+criteria.sourceSystem+" AND PARENT_SOURCE_SYSTEM_ID ="+criteria.targetSystem+") OR (CHILD_SOURCE_SYSTEM_ID = "+criteria.targetSystem+" AND PARENT_SOURCE_SYSTEM_ID ="+criteria.sourceSystem+")) AND ( CHILD_ENTITY_TYPE_ID="+criteria.sourceEntityType+" AND PARENT_ENTITY_TYPE_ID="+criteria.targetEntityType+")";

                    dbcmd.CommandText = sql;
                    using (IDataReader reader = dbcmd.ExecuteReader()) {
                        while(reader.Read()) {

                            int srcID    = Int32.Parse(reader["srcID"].ToString());
                            int targetID = Int32.Parse(reader["tarID"].ToString());
                            int relType = Int32.Parse(reader["relType"].ToString());
                            string relTypeDesc = reader["relDesc"].ToString();

                            retVal.Add(new EntityRelationship(srcID,targetID,relType,relTypeDesc));
                        }
                    }
                }
            }
            return retVal;
        }