/// <summary>
        /// Selects all objects from a given table in the database.
        /// This is SLOW SLOW SLOW.  You should cache these results rather than reading from the XML file each time.
        /// </summary>
        /// <param name="objectType">the type of objects to retrieve</param>
        /// <returns>an array of <see cref="DataObject" /> instances representing the selected objects</returns>
        protected override IList <TObject> SelectAllObjectsImpl <TObject>(IsolationLevel isolation)
        {
            string tableName = DataObject.GetTableName(typeof(TObject));

            Log.Debug("XMLObjectDatabase", "1. select all " + tableName);

            DataSet ds = GetDataSet(tableName);

            if (ds != null)
            {
                Connection.LoadDataSet(tableName, ds);
                System.Data.DataTable table = ds.Tables[tableName];
                DataRow[]             rows  = table.Select();

                int count = rows.Length;
                //Create an array of our destination objects
                var objs = new List <TObject>(count);

                for (int i = 0; i < count; i++)
                {
                    var remap = (TObject)(Activator.CreateInstance(typeof(TObject)));
                    FillObjectWithRow(ref remap, rows[i], false);

                    objs.Add(remap);
                }

                Log.Debug("XMLObjectDatabase", "2. select all " + tableName);

                return(objs);
            }

            return(new List <TObject>());
        }
示例#2
0
        // Lecture de la clef primaire
        public static string GetTableOrViewName(Type objectType)
        {
            string name = DataObject.GetViewName(objectType);

            // if not a view, we use tablename, else viewname
            if (string.IsNullOrEmpty(name))
            {
                return(DataObject.GetTableName(objectType));
            }

            return(name);
        }
示例#3
0
        /// <summary>
        /// Primary Key ID of a view
        /// </summary>
        /// <param name="objectType"></param>
        /// <returns></returns>
        public static string GetTableOrViewName(Type objectType)
        {
            // Graveen: introducing view selection hack (before rewriting the layer :D)
            // basically, a view must exist and is created with the following:
            //
            //	[DataTable(TableName="InventoryItem",ViewName = "MarketItem")]
            //	public class SomeMarketItems : InventoryItem {};
            //
            //  here, we rely on the view called MarketItem,
            //  based on the InventoryItem table. We have to tell to the code
            //  only to bypass the id generated with FROM by the above
            //  code.
            //
            string name = DataObject.GetViewName(objectType);

            // if not a view, we use tablename, else viewname
            if (string.IsNullOrEmpty(name))
            {
                return(DataObject.GetTableName(objectType));
            }

            return(name);
        }