public void GetTableNameTest()
        {
            var name = DbAttributesManager.GetTableName(typeof(TestWorkLogItem));

            Assert.AreEqual("WorkLogs", name);

            var tableName = DbAttributesManager.GetTableName(typeof(User));

            Assert.AreEqual("Users", tableName);
        }
Example #2
0
        /// <summary>
        /// Exports the specified types.
        /// </summary>
        /// <param name="types">The types.</param>
        /// <param name="ExportWithClean">if set to <c>true</c> than all existsing data will be removed first.</param>
        public void Export(Type[] types, bool ExportWithClean)
        {
            string     methodName = ExportWithClean ? "ExportWithClean" : "Export";
            MethodInfo method     = GetType().GetMethod(methodName, new Type[] {});

            DbStructureGateway structureGateway = new DbStructureGateway(Source);

            foreach (Type type in types)
            {
                string tableName = DbAttributesManager.GetTableName(type);

                if (structureGateway.IsTableExists(tableName))
                {
                    method.MakeGenericMethod(type).Invoke(this, null);
                }
            }
        }
Example #3
0
 /// <summary>
 /// Loads Count of Records
 /// </summary>
 /// <param name="type">Type to load</param>
 /// <returns>Records Count</returns>
 public ulong LoadCount(Type type)
 {
     return(Accessor.LoadCount(DbAttributesManager.GetTableName(type)));
 }
Example #4
0
        /// <summary>
        /// Removes objects from database
        /// </summary>
        /// <param name="type">Type which has DbAttributes</param>
        /// <param name="args">filter values</param>
        /// <returns>Count of removed objects</returns>
        /// <example>
        /// <code>
        /// uint count = DbGateway.Instance.Delete(typeof(WorkLog), "Type", WorkLogType.Default);
        /// </code>
        /// </example>
        public uint Delete(Type type, params object[] args)
        {
            string tableName = DbAttributesManager.GetTableName(type);

            return(Accessor.Delete(tableName, args));
        }
Example #5
0
        /// <summary>
        /// Exports the specified sheet to passed gateway and removes old data from passed gateway
        /// <example>
        /// <code>
        /// var target = new DbGateway(DbAccessor.Create("SampleDb"));
        /// var source = (ExcelAccessor)DbAccessor.Create("SampleExcelFile");
        ///
        /// source.ExportWithClean&lt;Contact&gt;(target, "Contacts");
        /// </code>
        /// </example>
        /// </summary>
        /// <typeparam name="T"></typeparam>
        /// <param name="targetGateway">The target gateway.</param>
        public void ExportWithClean <T>(DbGateway targetGateway) where T : class, new()
        {
            string tableName = DbAttributesManager.GetTableName(typeof(T));

            Export <T>(targetGateway, tableName);
        }
Example #6
0
 /// <summary>
 /// Checks is Associated Table Exists
 /// </summary>
 /// <param name="type"></param>
 /// <returns></returns>
 public bool IsTableExists(Type type)
 {
     return(IsTableExists(DbAttributesManager.GetTableName(type)));
 }