예제 #1
0
        public object Create(object parent, object configContext, XmlNode section)
        {
            var configuration = new DocumentDbConfiguration();

            if (section != null)
            {
                string sResult;
                int    iResult;
                bool   bResult;
                if (TryReadConfigurationValue(section, "metadataBuildStrategy/prefetchRows", out iResult))
                {
                    configuration.MetadataBuildStrategy.PrefetchRows = iResult;
                }
                if (TryReadConfigurationValue(section, "metadataBuildStrategy/fetchPosition", out sResult))
                {
                    configuration.MetadataBuildStrategy.FetchPosition = (FetchPosition)Enum.Parse(typeof(FetchPosition), sResult, true);
                }
                if (TryReadConfigurationValue(section, "metadataBuildStrategy/updateDynamically", out bResult))
                {
                    configuration.MetadataBuildStrategy.UpdateDynamically = bResult;
                }
                if (TryReadConfigurationValue(section, "metadataBuildStrategy/persistSchema", out bResult))
                {
                    configuration.MetadataBuildStrategy.PersistSchema = bResult;
                }
            }
            return(configuration);
        }
        /// <summary>Constructor</summary>
        public DocumentDbDataServiceBase(string connectionString, DocumentDbConfiguration dbConfiguration)
        {
            this.connectionString     = connectionString;
            this.dbConfiguration      = dbConfiguration;
            this.createUpdateProvider = () => new DocumentDbDSPUpdateProvider(this.connectionString, this.CurrentDataSource, this.dbMetadata);

            ResetDataContext = x =>
            {
                this.dbMetadata = new DocumentDbMetadata(x, this.dbConfiguration == null ? null : this.dbConfiguration.MetadataBuildStrategy);
                DocumentDbDataServiceBase <T, Q> .context = this.CreateContext(x);
            };

            ResetDataContext(connectionString);
        }