title: MVC 4 C# How to create a method that returns a list<object>
body: <p>I am using EF and seeding our DB with some product data. The data with which I'm seeding has a part which will be repeated about 100 times. Rather than copy and paste my code I would rather populate my list with a method but as I am a newbie, I cannot seem to make this work properly:</p>
  
  <p>Here is the code in context:</p>
  
  <pre><code>context.Products.AddOrUpdate(
              pr =&gt; pr.Name,
              new Product
              {
                  Name = "3.5x5",
                  ProductCategoryId = 1,
                  ProductSubCategoryId1 = 1,
                  ProductSubCategoryId2 = 3,
                  VendorId = 1,
                  HeightUnitId = 2,
                  Height = (decimal)3.5,
                  Width = 5,
                  ProductOptions =
                  new List&lt;ProductOption&gt;
                  {
                      new ProductOption { Name = "Paper", InputTypeSingleOptionId = 1, InputTypeMultipleOptionId = 2, SortOrder = 1,
                          ProductOptionsDetails =
                          new List&lt;ProductOptionsDetail&gt;
                          {
                              new ProductOptionsDetail { Name = "Glossy", Value = "Glossy", IsDefault = true, SortOrder = 1 },
                              new ProductOptionsDetail { Name = "Matte", Value = "Matte", IsDefault = false, SortOrder = 2 },
                              new ProductOptionsDetail { Name = "Metallic", Value = "Metallic", IsDefault = false, SortOrder = 3 },
                              new ProductOptionsDetail { Name = "Lustre", Value = "Lustre", IsDefault = false, SortOrder = 4 }
                          }
                      },
                      new ProductOption { Name = "Color", InputTypeSingleOptionId = 1, InputTypeMultipleOptionId = 2, SortOrder = 2,
                          ProductOptionsDetails =
                          new List&lt;ProductOptionsDetail&gt;
                          {
                              new ProductOptionsDetail { Name = "Color", Value = "Color", IsDefault = true, SortOrder = 1 },
                              new ProductOptionsDetail { Name = "Black and white", Value = "Black and White", IsDefault = false, SortOrder = 2 },
                              new ProductOptionsDetail { Name = "Sepia", Value = "Sepia", IsDefault = false, SortOrder = 3 }
                          } 
                      },
                      new ProductOption { Name = "Texture", InputTypeSingleOptionId = 1, InputTypeMultipleOptionId = 2, SortOrder = 3,
                          ProductOptionsDetails =
                          new List&lt;ProductOptionsDetail&gt;
                          {
                              new ProductOptionsDetail { Name = "None", Value = "None", IsDefault = true, SortOrder = 1 },
                              new ProductOptionsDetail { Name = "Linen texture", Value = "Linen", IsDefault = false, SortOrder = 2 },                         
                              new ProductOptionsDetail { Name = "Canvas texture", Value = "Canvas", IsDefault = false, SortOrder = 3 },
                              new ProductOptionsDetail { Name = "Watercolor texture", Value = "Canvas", IsDefault = false, SortOrder = 4 },
                              new ProductOptionsDetail { Name = "Pebble texture", Value = "Pebble", IsDefault = false, SortOrder = 5 }
                          }
                      },
                      new ProductOption { Name = "Coating", InputTypeSingleOptionId = 1, InputTypeMultipleOptionId = 2, SortOrder = 4,
                          ProductOptionsDetails =
                          new List&lt;ProductOptionsDetail&gt;
                          {
                              new ProductOptionsDetail { Name = "None", Value = "None", IsDefault = true, SortOrder = 1 },
                              new ProductOptionsDetail { Name = "Linen texture", Value = "Linen", IsDefault = false, SortOrder = 2 },                         
                              new ProductOptionsDetail { Name = "Canvas texture", Value = "Canvas", IsDefault = false, SortOrder = 3 },
                              new ProductOptionsDetail { Name = "Watercolor texture", Value = "Canvas", IsDefault = false, SortOrder = 4 },
                              new ProductOptionsDetail { Name = "Pebble texture", Value = "Pebble", IsDefault = false, SortOrder = 5 }
                          }
                      }
                  }
              },
  </code></pre>
  
  <p>The part I would like to return from a method would be something like: 
  <strong>ProductOptions = getOptions()</strong> All that nested code can be repeated verbatim. I have tried working from some other examples but I keep on getting errors in Visual Studio. If I could get a very basic approach to this, that would be greatly appreciated.</p>