动态执行linq 语句 NLinq

时间:2024-04-22 17:34:00

using Evaluant.NLinq.Memory;
using System.Collections.Generic;
using Evaluant.NLinq;
using System.Collections;
using Microsoft.VisualStudio.TestTools.UnitTesting;

#region test

LinqToMemory linq;
            NLinqQuery query;
            MyHotelDataContext dataContext = new MyHotelDataContext();
            var v = from t in dataContext.T1_Area  where t.AreaEN.Contains("d") select t;
            //query = new NLinqQuery(@"from t in T1_Area where t.Code.Trim()==AA select t");
            //query = new NLinqQuery(@"from t in T1_Area where t.AreaCN==AA select t");
            query = new NLinqQuery(@"from t in T1_Area where t.AreaCN.Contains(AA) select t");
            List<object> n = new List<object>();

linq = new LinqToMemory(query);
            linq.SetParameter("T1_Area", dataContext.T1_Area);
            linq.SetParameter("AA", "欧洲");
            IList where1 = linq.List();

Assert.AreEqual(2, where1.Count);

#endregion