<commit_before>﻿using System.Collections.Generic;
using System.Linq;
using Microsoft.SqlServer.Dac.Extensions.Prototype;
using Microsoft.SqlServer.Dac.Model;

namespace SSDTDevPack.Common.Dac
{
    public class TableRepository
    {
        private readonly string _path;

        public TableRepository(string path)
        {
            _path = path;
        }

        public List<TableDescriptor> Get()
        {
            var model = Model.Get(_path);
            var dacTables = model.GetObjects<TSqlTable>(DacQueryScopes.UserDefined);

            var tables = dacTables.Select(t => new TableDescriptor(t)).ToList();

            Model.Close(model);

            return tables;
        }
    }
}<commit_msg>adding cache to tablerepository<commit_after>﻿using System.Collections.Generic;
using System.Linq;
using Microsoft.SqlServer.Dac.Extensions.Prototype;
using Microsoft.SqlServer.Dac.Model;

namespace SSDTDevPack.Common.Dac
{
    public class TableRepository
    {
        private readonly string _path;
        private List<TableDescriptor> _tables; 

        public TableRepository(string path)
        {
            _path = path;
        }
        

        public List<TableDescriptor> Get()
        {
            if (_tables == null)
                BuildTables();

            return _tables;
        }

        private void BuildTables()
        {
            var model = Model.Get(_path);
            var dacTables = model.GetObjects<TSqlTable>(DacQueryScopes.UserDefined);

            _tables = dacTables.Select(t => new TableDescriptor(t)).ToList();

            Model.Close(model);

        }
    }
}
{'fraction_non_alphanumeric': 0.0910209102091021, 'fraction_numerical': 0.0, 'mean_word_length': 2.140926640926641, 'pattern_counts': {'":': 0, '<': 8, '<?xml version=': 0, '>': 10, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '6342625', 'n_tokens_mistral': 451, 'n_tokens_neox': 435, 'n_words': 90}