Esempio n. 1
0
        public void Save()
        {
            if (!EntitySchemaManager.TryGetSchema(GetType(), out IEntitySchema view))
            {
                throw new ArgumentException();
            }
            if (!DbFactory.TryGet(view.ConnectKey, out IDbProvider dbProvider))
            {
                throw new InvalidOperationException("not found DbProvider:" + view.ConnectKey);
            }

            switch (saveUsage)
            {
            case SaveUsage.Update:
                DbHelper.Update(dbProvider, new object[] { this });
                break;

            case SaveUsage.Insert:
                DbHelper.Insert(dbProvider, new object[] { this });
                break;

            default:
                throw new InvalidOperationException(string.Format("unknown {0}:{1}", nameof(SaveUsage), saveUsage));
            }
        }
Esempio n. 2
0
        public void Save()
        {
            if (!EntitySchemaManager.TryGetSchema(GetType(), out IEntitySchema view))
            {
                throw new ArgumentException();
            }
            if (!DbConnectionManager.TryGet(view.ConnectKey, out DbConnectionProvider connectionProvider))
            {
                throw new InvalidOperationException("not found DbProvider:" + view.ConnectKey);
            }

            switch (_saveUsage)
            {
            case SaveUsage.Unknown:
                throw new InvalidOperationException("Unknown SaveUsage");

            case SaveUsage.Update:
                connectionProvider.Update(new object[] { this });
                break;

            case SaveUsage.Insert:
                connectionProvider.Insert(new object[] { this });
                break;
            }
        }