示例#1
0
        public void TestDirect(string context)
        {
            using (var db = new DataConnection(context))
            {
                db.Execute(@"
	DROP TABLE IF EXISTS dataFTS;
	CREATE VIRTUAL TABLE dataFTS USING fts4(`ID` INTEGER, `FirstName` TEXT, `LastName` TEXT, `MidName` TEXT )"    );

                try
                {
                    var data = db.GetTable <DtaFts>()
                               .Where(arg => SqlLite.MatchFts <DtaFts>("John*"))
                               .Select(result =>
                                       new
                    {
                        result.FirstName,
                        result.MidName,
                        result.LastName,
                    });

                    var list = data.ToList();                     // <=THROWS EXCEPTION

                    Assert.AreEqual(0, list.Count);

                    db.GetTable <DtaFts>()
                    .Insert(() => new DtaFts()
                    {
                        FirstName = "JohnTheRipper"
                    });
                    db.GetTable <DtaFts>()
                    .Insert(() => new DtaFts()
                    {
                        FirstName = "DoeJohn"
                    });

                    list = data.ToList();                     // <=THROWS EXCEPTION

                    Assert.AreEqual(1, list.Count);
                    Assert.AreEqual("JohnTheRipper", list[0].FirstName);
                }
                finally
                {
                    // cleanup
                    db.Execute("DROP TABLE dataFTS");
                }
            }
        }