コード例 #1
0
ファイル: TableFinder.cs プロジェクト: Bunyod545/SBFramework
        /// <summary>
        ///
        /// </summary>
        /// <param name="contextInfo"></param>
        /// <returns></returns>
        private List <EFTableInfo> GetTable(TableContextInfo contextInfo)
        {
            if (!(Activator.CreateInstance(contextInfo.ContextType) is DbContext context))
            {
                return(new List <EFTableInfo>());
            }

            var entityTypes = contextInfo.TableTypes.Select(context.Model.FindEntityType);

            return(entityTypes.Select(s => ConvertToTableInfo(context, s)).ToList());
        }
コード例 #2
0
ファイル: TableFinder.cs プロジェクト: Bunyod545/SBFramework
        /// <summary>
        ///
        /// </summary>
        /// <param name="contextInfo"></param>
        /// <param name="histories"></param>
        /// <returns></returns>
        private bool IsCanMigrate(TableContextInfo contextInfo, List <MigrationHistory> histories)
        {
            var history = histories.FirstOrDefault(f => f.Name == contextInfo.ContextType.Name);

            if (history == null)
            {
                return(true);
            }

            var historyVersion = new Version(history.Version);

            return(historyVersion < contextInfo.MigrateVersion);
        }
コード例 #3
0
        /// <summary>
        ///
        /// </summary>
        /// <param name="contextType"></param>
        /// <returns></returns>
        private static TableContextInfo GetMigrateContextType(Type contextType)
        {
            var attr = contextType?.GetCustomAttribute <SbMigrationAttribute>();

            if (attr == null || contextType.IsAbstract)
            {
                return(null);
            }

            var tableTypes = GetContextTables(contextType);

            if (tableTypes.IsNullOrEmpty())
            {
                return(null);
            }

            var info = new TableContextInfo(contextType, attr.Version);

            info.TableTypes = tableTypes;

            return(info);
        }