root/src/FmwkPoiesis.ObjectSearchProvider.Linq/LinqObjectSearchProvider.cs

34
2
using System.Collections.Generic;
2
using System.Collections.Generic;
3
using System.Linq;
3
using System.Linq;
4
using System.Text;
4
using System.Text;
5
using Poiesis.FrameWork.ObjectSearch; 
5
using Poiesis.FrameWork.ObjectSearch;
6
6
7
namespace FmwkPoiesis.ObjectSearchProvider.Linq
7
namespace FmwkPoiesis.ObjectSearchProvider.Linq
8
{
8
{
9
	public class LinqObjectSearchProvider : IObjectSearchProvider 
9
	public class LinqObjectSearchProvider : IObjectSearchProvider
10
	{
10
	{
11
		public string Name
12
		{
13
			get { return "LinqProvider"; }
14
		}
15
11
		public string BuildCommandEqual<T>(Equal<T> comparator, bool isLast) where T : IComparable
16
		public string BuildCommandEqual<T>(Equal<T> comparator, bool isLast) where T : IComparable
12
		{
17
		{
13
			string command = String.Format("({0} = {1})", comparator.NameProperty, comparator.ValueToCompare.ToString());
18
			string command = String.Format("|{0} = {1}|", comparator.NameProperty, comparator.ValueToCompare.ToString());
14
19
15
			if ( isLast)
20
			if (isLast)
16
				return command;
21
				return command;
17
22
18
			if (comparator.And)
23
			if (comparator.And)
...
...
20
			else
25
			else
21
				return command + " or ";
26
				return command + " or ";
22
		}
27
		}
28
29
		public string BuildCommandRange<T>(Range<T> comparator, bool isLast) where T : IComparable
30
		{
31
			string command = String.Format("|{0} >= {1} and {0} <= {2}|", comparator.NameProperty, comparator.MinValue.ToString(),
comparator.MaxValue.ToString() );
32
33
			if (isLast)
34
				return command;
35
36
			if (comparator.And)
37
				return command + " and ";
38
			else
39
				return command + " or ";
40
		}
41
23
	}
42
	}
24
}
43
}