facebooklinq /Source/facebook.Linq/Linq/Provider.cs

Language C# Lines 73
MD5 Hash 8f328be8acbfe383a4d160ced819f2c3 Estimated Cost $1,261 (why?)
Repository https://bitbucket.org/assaframan/facebooklinq.git View Raw File View Project SPDX
 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Linq.Expressions;
using System.Data.Linq;
using System.Collections;
using facebook.Linq;
using facebook;

namespace facebook.Linq
{
	class FqlProvider : IFqlProvider
	{
		public FqlProvider(API api)
		{
			Api = api;
		}
		API Api;

		#region IMyProvider Members

		public System.Data.Linq.IExecuteResult Execute(System.Linq.Expressions.Expression query, Type tableRowType)
		{
			var builder = new FqlQueryBuilder(query);
			var fql = builder.BuildQuery();
			var resultType = query.Type;//
			if (resultType.IsGenericType)
					resultType = resultType.GetGenericArguments()[0];
			if (fql.StartsWith("from "))
				fql = "select * " + fql;
			
			
			//QueryBuilder2
			//var builder = new FqlQueryBuilder(query);
			//var fql = builder.BuildQuery();
			//var select = builder.Select;
			//var resultType = query.Type.GetGenericArguments()[0];
			fql = FqlDataContext.FixQuery(fql);
			var response = ExecuteFqlQuery(fql);
			return new FqlExecuteResult(response, resultType, tableRowType, builder.QueryOptions);
		}

		public string GetQueryText(System.Linq.Expressions.Expression query)
		{
			var builder = new FqlQueryBuilder(query);
			var fql = builder.BuildQuery();
			return fql;
		}

		public SqlNode GetSqlTree(Expression query)
		{
			//var builder = new FqlQueryBuilder2(query);
			//return builder.GetSqlExpressionTree();
			throw new Exception();
		}
		#endregion

		#region IFqlProvider Members

		public System.IO.TextWriter Log{get;set;}

		public string ExecuteFqlQuery(string query)
		{
			if (Log != null)
				Log.WriteLine("Executing Fql: " + query);
			return Api.fql.query(query);
		}

		#endregion
	}
}
Back to Top