Exemplo n.º 1
0
        public void CreateTable(IDictionary <string, string[]> seedValues = null)
        {
            TEntity dummyEntity = (TEntity)Activator.CreateInstance(typeof(TEntity));

            if (seedValues != null)
            {
                Type           type     = typeof(TEntity);
                PropertyInfo[] propInfo = type.GetProperties();

                byte entityNumber = (byte)(seedValues.Values.Count / seedValues.Keys.Count);

                for (byte entityCounter = 0; entityCounter < entityNumber; entityCounter++)
                {
                    foreach (string key in seedValues.Keys)
                    {
                        type.GetProperty(key).SetValue(dummyEntity, seedValues[key][entityCounter]);
                    }

                    _repo.CreateEntity(dummyEntity);
                    dummyEntity = (TEntity)Activator.CreateInstance(typeof(TEntity));
                }
            }
        }