A similar statement can be performed using the Contains function:
var query = from p in context.Persons where p.Name.Contains("abc") select p;
An index must be added by SQL - there is no special construct in EF to create an index. You can execute this SQL with DB initialization.
First you must implement a custom initializer:
public class MyInitializer : CreateDatabaseIfNotExists<MyContext> { protected override void Seed(MyContext context) { context.Database.SqlCommand("CREATE INDEX IX_Person_Name ON Person (Name)"); } }
Then you must register a new initializer:
DbDatabase.SetInitializer<MyContext>(new MyInitializer());
Ladislav Mrnka Feb 18 '11 at 12:23 2011-02-18 12:23
source share