예제 #1
0
        protected override IVsDataReader SelectObjects(string typeName, object[] restrictions, string[] properties, object[] parameters)
        {
            IVsDataReader dataReader;

            var connection = (SqliteConnection)Site.GetLockedProviderObject();

            try
            {
                Site.EnsureConnected();

                var dataTable = new DataTable
                {
                    Columns =
                    {
                        { "DatabaseName" }
                    },
                    Rows =
                    {
                        new object[]
                        {
                            Path.GetFileNameWithoutExtension(connection.DataSource)
                        }
                    }
                };

                if (parameters?.Length == 1)
                {
                    ApplyMappings(dataTable, GetMappings((object[])((DictionaryEntry)parameters[0]).Value));
                }

                dataReader = new AdoDotNetTableReader(dataTable);
            }
            finally
            {
                Site.UnlockProviderObject();
            }

            return(dataReader);
        }
예제 #2
0
        protected override IVsDataReader SelectObjects(
            string typeName,
            object[] restrictions,
            string[] properties,
            object[] parameters)
        {
            IVsDataReader dataReader;

            var connection = (SqliteConnection)Site.GetLockedProviderObject();

            try
            {
                Site.EnsureConnected();

                var collectionName = (string)parameters[0];
                if (!_objectSelectors.TryGetValue(collectionName, out var selectObjects))
                {
                    // TODO: Resourcify
                    throw new ArgumentException($"The requested collection ({collectionName}) is not defined.");
                }

                var dataTable = selectObjects(
                    connection,
                    restrictions ?? Array.Empty <object>());

                if (parameters.Length == 2)
                {
                    ApplyMappings(dataTable, GetMappings((object[])((DictionaryEntry)parameters[1]).Value));
                }

                dataReader = new AdoDotNetTableReader(dataTable);
            }
            finally
            {
                Site.UnlockProviderObject();
            }

            return(dataReader);
        }