Beispiel #1
0
        public static void CopyFromDMS <T>(this IDMSObject <T> source, string sqlStatement) where T : class
        {
            ADODB.Recordset rs = DMSConnection.GetInstance().Recordset(sqlStatement);
            if (rs == null)
            {
                return;
            }
            if (rs.BOF && rs.EOF)
            {
                return;
            }

            PropertyInfo[] properties = typeof(T).GetProperties();

            for (int i = 0; i < rs.Fields.Count; i++)
            {
                foreach (PropertyInfo property in properties)
                {
                    if (property.Name == rs.Fields[i].Name)
                    {
                        object value = rs.Fields[i].Value;
                        if (value is DBNull)
                        {
                            value = -1;
                        }
                        property.SetValue(source, Convert.ChangeType(value, property.PropertyType));
                    }
                }
            }
        }
Beispiel #2
0
        public static ICollection <T> GetDMSObjects <T>(this IDMSObject <T> source, string sqlstatement) where T : class, new()
        {
            ICollection <T> retVal = GetDataCollection <T>(sqlstatement, "", DMSConnection.GetInstance());

            // DMSConnection.GetInstance().Connection.Close();
            return(retVal);
        }