예제 #1
0
        public static String Relinq(String serialized)
        {
            var asm = Assembly.Load("Relinq.Playground");
            var ctxType = asm.GetType("Relinq.Playground.DataContexts.TestServerDataContext");
            var ctx = Activator.CreateInstance(ctxType);

            var transformationFramework = new TransformationFramework();
            transformationFramework.Integration.RegisterJS("ctx", ctx);

            var queryAtServer = transformationFramework.JSToCSharp(serialized);
            var resultAtServer = queryAtServer.Evaluate();
            var serializedResultAtServer = JsonSerializer.Serialize(resultAtServer, queryAtServer.Type);
            return serializedResultAtServer;
        }
예제 #2
0
        public void SimpleTest10()
        {
            var tf = new TransformationFramework();
            tf.Integration.RegisterJS("items", new List<ItemFactory>{new ItemFactory(), new ItemFactory()});

            var js = "items.Select(function(c){return {I:c.Item()}})";
            var result = tf.JSToCSharp(js).Evaluate();

            var ints = new List<int>();
            foreach(var anon in (IEnumerable)result)
                ints.Add((int)anon.GetType().GetProperty("I").GetValue(anon, null));

            Assert.IsTrue(ints.SequenceEqual(Enumerable.Range(1, 2)));
        }
예제 #3
0
        public void SimpleTest8()
        {
            var tf = new TransformationFramework();
            tf.Integration.RegisterJS("iec", new List<Company>());

            var js = "iec.Where(function(c){return c.Name=='a'}).Select(function(c){return c.Name})";
            var et = tf.JSToCSharp(js);

            Expression<Func<IEnumerable<Company>, IEnumerable<String>>> linq = iec =>
                from c in iec where c.Name == "a" select c.Name;

            var relinq = et.Evaluate();
            var native = linq.Compile()(new List<Company>());
        }