Using the Entity Framework to create an index and the following code:
var op = new CreateIndexOperation
{
Columns = { "COL_A", "COL_B", "COL_C" },
IsUnique = true,
Name = "INDEX_NAME",
Table = "TABLE_NAME"
});
This compiles and works as expected. Trying to reorganize this into the following method (simplified for this example):
private void AddIndex(params string[] columns)
{
var op = new CreateIndexOperation
{
Columns = columns.ToList(),
IsUnique = true,
Name = "INDEX_NAME",
Table = "TABLE_NAME"
});
}
This method throws the following compiler error:
Property or Indexer 'IndexOperation.Columns' cannot be assigned to -- it is read only
Looking at the MSDN documentation , it looks right, and the property Columnshas no setter. However, if so, why does the first block of code not throw a compiler error, and the second does, where am I trying to set this value from a variable?
source
share