Exemple #1
0
        /// <summary>
        /// Méthode static pour appelé p_Delete.
        /// Cf p_Delete() pour plus d'infos.
        /// </summary>
        /// <param name="persistableObject"></param>
        static public void Delete(IEnumerable persistableObjects)
        {
            PersistDAL dal = new PersistDAL();

            dal.p_Delete(persistableObjects);
            dal = null;
        }
Exemple #2
0
        /// <summary>
        /// Méthode static pour appelé p_Read.
        /// Cf p_Read() pour plus d'infos.
        /// </summary>
        /// <param name="persistableObject"></param>
        static public void Read(object persistableObject)
        {
            PersistDAL dal = new PersistDAL();                  // on créer une instance qui sera chargé du traitement

            dal.p_Read(persistableObject);
            dal.dbhelper.CloseConnection();
            dal = null;
        }
Exemple #3
0
        static public void Insert(IEnumerable persistableObjects)
        {
            PersistDAL dal = new PersistDAL();

            dal.p_Insert(persistableObjects);
            dal.dbhelper.Commit();
            dal.dbhelper.CloseConnection();
            dal = null;
        }
Exemple #4
0
 /// <summary>
 /// Méthode static pour appelé p_Delete.
 /// Cf p_Delete() pour plus d'infos.
 /// </summary>
 /// <param name="persistableObject"></param>
 static public void Delete(object persistableObject)
 {
     if (persistableObject is IEnumerable)
     {
         PersistDAL.Delete(persistableObject as IEnumerable);
     }
     else
     {
         PersistDAL.Delete(new object[] { persistableObject });
     }
 }
Exemple #5
0
 /// <summary>
 /// Méthode static pour appelé p_Insert.
 /// Cf p_Insert() pour plsu d'infos.
 /// </summary>
 /// <param name="persistableObject"></param>
 static public void Insert(object persistableObject)
 {
     if (persistableObject is IEnumerable)
     {
         PersistDAL.Insert(persistableObject as IEnumerable);
     }
     else
     {
         PersistDAL.Insert(new object[] { persistableObject });
     }
 }
Exemple #6
0
 /// <summary>
 /// Methode statique update permettant de grouper l'update de plusieur objets au sein de la meme
 /// transaction.
 /// </summary>
 /// <param name="persistableObjects"></param>
 public static void Update(IEnumerable persistableObjects)
 {
     PersistDAL dal=new PersistDAL();
     dal.p_Update(persistableObjects);
     dal.dbhelper.Commit();
     dal.dbhelper.CloseConnection();
     dal=null;
 }
Exemple #7
0
 public static ArrayList ReadMultiple(object persistableObject,string top,string where,string orderby,string groupby)
 {
     PersistDAL dal=new PersistDAL();	// on créer une instance qui sera chargé du traitement
     return dal.p_ReadMultiple(persistableObject,top,where,orderby,groupby);
 }
Exemple #8
0
 /// <summary>
 /// Méthode static pour appelé p_Read. 
 /// Cf p_Read() pour plus d'infos.
 /// </summary>
 /// <param name="persistableObject"></param>
 public static void Read(object persistableObject)
 {
     PersistDAL dal=new PersistDAL();	// on créer une instance qui sera chargé du traitement
     dal.p_Read(persistableObject);
     dal.dbhelper.CloseConnection();
     dal=null;
 }
Exemple #9
0
 public static ArrayList Query(Type persistableObjectType,params SQLRequestElement[] sqle)
 {
     PersistDAL dal=new PersistDAL();
     return dal.p_Query(persistableObjectType,sqle);
 }
Exemple #10
0
 /// <summary>
 /// Méthode static pour appelé p_Delete. 
 /// Cf p_Delete() pour plus d'infos.
 /// </summary>
 /// <param name="persistableObject"></param>
 public static void Delete(IEnumerable persistableObjects)
 {
     PersistDAL dal=new PersistDAL();
     dal.p_Delete(persistableObjects);
     dal=null;
 }
Exemple #11
0
        internal ArrayList p_ReadMultiple(object persistableObject, string top, string where, string orderby, string groupby)
        {
            PersistDataSourceAttribute       pdsa;                    // contient les requetes utile pour l'acces au données
            PersistConnectionStringAttribute pcs;                     // contient l'attribut de la chaine de connexion
            ArrayList  alPrimaryKeys;                                 // contient la liste des clés primaire
            SortedList slFieldsValue;                                 // contient la liste des champs et leur valeurs

            Type persistableObjectType = persistableObject.GetType(); // on recupere les informations sur le type de l'objet a persister

            ArrayList alAggregatedObjects = GetAggregatedObject(persistableObject);

            GetDatabaseInformation(persistableObjectType, out pdsa, out pcs);

            // on recupere les infos sur les cle primaires
            CreateFieldAndPKeyList(persistableObjectType, out alPrimaryKeys, out slFieldsValue);

            ArrayList alMultObject = new ArrayList();
            string    reqSql       = "SELECT";

            if (top != null)
            {
                reqSql += " TOP " + top;
            }

            reqSql += " ";

            string separateur = "";

            foreach (string pk in alPrimaryKeys)
            {
                PersistFieldInfo pfi = (PersistFieldInfo)slFieldsValue[pk];
                reqSql    += separateur + pfi.DBFieldName;
                separateur = ",";
            }
            if (groupby != null)
            {
                reqSql += separateur + groupby;
            }

            reqSql += " FROM " + pdsa.TableName;
            if (where != null)
            {
                reqSql += " WHERE " + where;
            }
            if (groupby != null)
            {
                reqSql += " GROUP BY " + groupby;
            }
            if (orderby != null)
            {
                reqSql += " ORDER BY " + orderby;
            }

            // on se connecte a la base de donnée en utilisant la chaine de connection présent dans l'attribut [PersistConnectionString]
            IDbConnection cnx = dbhelper.GetConnection(pcs.ConnectionString);
            IDbCommand    cmd = dbhelper.GetNewCommand(reqSql);

            cmd.Connection = cnx;
            IDataReader rdr = cmd.ExecuteReader();
            Type        tpo = persistableObject.GetType();

            while (rdr.Read())
            {
                SortedList slNewFieldValue = new SortedList();
                object     npo             = Activator.CreateInstance(tpo);
                foreach (string pk in alPrimaryKeys)
                {
                    PersistFieldInfo pfi = (PersistFieldInfo)slFieldsValue[pk];
                    pfi.SetInstanceValue(npo, rdr[pfi.DBFieldName]);
                }
                PersistDAL.Read(npo);
                alMultObject.Add(npo);
            }
            rdr.Close();
            rdr.Dispose();
            cmd.Dispose();
            dbhelper.GetConnection("").Close();

            return(alMultObject);
        }
Exemple #12
0
        static public ArrayList ReadMultiple(object persistableObject, string top, string where, string orderby, string groupby)
        {
            PersistDAL dal = new PersistDAL();                  // on créer une instance qui sera chargé du traitement

            return(dal.p_ReadMultiple(persistableObject, top, where, orderby, groupby));
        }
Exemple #13
0
        internal ArrayList p_Query(Type persistableObjectType, params SQLRequestElement[] sqle)
        {
            throw new PersistException("Not implemented");

            PersistDataSourceAttribute       pdsa; // contient les requetes utile pour l'acces au données
            PersistConnectionStringAttribute pcs;  // contient l'attribut de la chaine de connexion
            ArrayList  alPrimaryKeys;              // contient la liste des clés primaire
            SortedList slFieldsValue;              // contient la liste des champs et leur valeurs


            //ArrayList alAggregatedObjects=GetAggregatedObject(persistableObject);
            GetDatabaseInformation(persistableObjectType, out pdsa, out pcs);

            // on recupere les infos sur les cle primaires
            CreateFieldAndPKeyList(persistableObjectType, out alPrimaryKeys, out slFieldsValue);

            ArrayList alMultObject = new ArrayList();

            // ICI : appel du dbhelper pour contruire la requete SQL !
            string reqSql = "";
//////			if (top!=null) reqSql+=" TOP " + top;
//////
//////			reqSql+=" ";
//////
//////			string separateur="";
//////			foreach(string pk in alPrimaryKeys)
//////			{
//////				PersistFieldInfo pfi=(PersistFieldInfo)slFieldsValue[pk];
//////				reqSql+=separateur + pfi.DBFieldName;
//////				separateur=",";
//////			}
//////			if (groupby!=null) reqSql+=separateur+groupby;
//////
//////			reqSql+=" FROM " + pdsa.TableName;
//////			if (where!=null) reqSql+=" WHERE " + where;
//////			if (groupby!=null) reqSql+=" GROUP BY " + groupby;
//////			if (orderby!=null) reqSql+=" ORDER BY " + orderby;
//////
            // on se connecte a la base de donnée en utilisant la chaine de connection présent dans l'attribut [PersistConnectionString]
            IDbConnection cnx = dbhelper.GetConnection(pcs.ConnectionString);
            IDbCommand    cmd = dbhelper.GetNewCommand(reqSql);

            cmd.Connection = cnx;
            IDataReader rdr = cmd.ExecuteReader();
            Type        tpo = persistableObjectType;

            while (rdr.Read())
            {
                SortedList slNewFieldValue = new SortedList();
                object     npo             = Activator.CreateInstance(tpo);
                foreach (string pk in alPrimaryKeys)
                {
                    PersistFieldInfo pfi = (PersistFieldInfo)slFieldsValue[pk];
                    pfi.SetInstanceValue(npo, rdr[pfi.DBFieldName]);
                }
                PersistDAL.Read(npo);
                alMultObject.Add(npo);
            }
            rdr.Close();
            rdr.Dispose();
            cmd.Dispose();
            dbhelper.GetConnection("").Close();

            return(alMultObject);
        }
Exemple #14
0
        static public ArrayList Query(Type persistableObjectType, params SQLRequestElement[] sqle)
        {
            PersistDAL dal = new PersistDAL();

            return(dal.p_Query(persistableObjectType, sqle));
        }