Browse files

Just doing some cleaning up

  • Loading branch information...
1 parent 6e7b5df commit be2bb27c5ef4801c7649ebd8b9ee3fd4d2a56fcb @markrendle committed Mar 16, 2012
View
4 CommonAssemblyInfo.cs
@@ -19,6 +19,6 @@
// COM, set the ComVisible attribute to true on that type.
[assembly: ComVisible(false)]
-[assembly: AssemblyVersion("1.0.0.3")]
-[assembly: AssemblyFileVersion("1.0.0.3")]
+[assembly: AssemblyVersion("1.0.0.4")]
+[assembly: AssemblyFileVersion("1.0.0.4")]
View
3 Simple.Data.Ado/AdoAdapter.cs
@@ -3,14 +3,11 @@
using System.ComponentModel.Composition;
using System.Data;
using System.Data.Common;
-using System.Data.SqlClient;
using System.Linq;
using Simple.Data.Ado.Schema;
namespace Simple.Data.Ado
{
- using Extensions;
-
[Export("Ado", typeof (Adapter))]
public partial class AdoAdapter : Adapter, ICloneable
{
View
4 Simple.Data.Ado/Simple.Data.Ado.nuspec
@@ -2,7 +2,7 @@
<package xmlns="http://schemas.microsoft.com/packaging/2010/07/nuspec.xsd">
<metadata>
<id>Simple.Data.Ado</id>
- <version>1.0.0-beta3</version>
+ <version>1.0.0-beta4</version>
<authors>Mark Rendle</authors>
<owners>Mark Rendle</owners>
<description>ADO Adapter for the Simple.Data data access library.</description>
@@ -12,7 +12,7 @@
<tags>sqlserver database data ado .net40</tags>
<language>en-us</language>
<dependencies>
- <dependency id="Simple.Data.Core" version="1.0.0-beta3" />
+ <dependency id="Simple.Data.Core" version="1.0.0-beta4" />
</dependencies>
</metadata>
</package>
View
4 Simple.Data.Mocking/Simple.Data.Mocking.nuspec
@@ -2,7 +2,7 @@
<package xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
<metadata xmlns="http://schemas.microsoft.com/packaging/2010/07/nuspec.xsd">
<id>Simple.Data.Mocking</id>
- <version>1.0.0-beta3</version>
+ <version>1.0.0-beta4</version>
<authors>Mark Rendle</authors>
<owners>Mark Rendle</owners>
<description>XML-based Mocking adapter for the Simple.Data data access library.</description>
@@ -12,7 +12,7 @@
<tags>database data .net40</tags>
<language>en-us</language>
<dependencies>
- <dependency id="Simple.Data.Ado" version="1.0.0-beta3" />
+ <dependency id="Simple.Data.Ado" version="1.0.0-beta4" />
</dependencies>
</metadata>
</package>
View
4 Simple.Data.SqlCe40/Simple.Data.SqlCe40.nuspec
@@ -2,7 +2,7 @@
<package xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
<metadata xmlns="http://schemas.microsoft.com/packaging/2010/07/nuspec.xsd">
<id>Simple.Data.SqlCompact40</id>
- <version>1.0.0-beta3</version>
+ <version>1.0.0-beta4</version>
<authors>Mark Rendle</authors>
<owners>Mark Rendle</owners>
<description>SQL Server Compact 4.0 ADO provider for the Simple.Data data access library.</description>
@@ -12,7 +12,7 @@
<tags>sqlserver compact sqlce database data ado .net40</tags>
<language>en-us</language>
<dependencies>
- <dependency id="Simple.Data.Ado" version="1.0.0-beta3" />
+ <dependency id="Simple.Data.Ado" version="1.0.0-beta4" />
</dependencies>
</metadata>
</package>
View
4 Simple.Data.SqlServer/Simple.Data.SqlServer.nuspec
@@ -2,7 +2,7 @@
<package xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
<metadata xmlns="http://schemas.microsoft.com/packaging/2010/07/nuspec.xsd">
<id>Simple.Data.SqlServer</id>
- <version>1.0.0-beta3</version>
+ <version>1.0.0-beta4</version>
<authors>Mark Rendle</authors>
<owners>Mark Rendle</owners>
<description>SQL Server ADO provider for the Simple.Data data access library.</description>
@@ -12,7 +12,7 @@
<tags>sqlserver database data ado .net40</tags>
<language>en-us</language>
<dependencies>
- <dependency id="Simple.Data.Ado" version="1.0.0-beta3" />
+ <dependency id="Simple.Data.Ado" version="1.0.0-beta4" />
</dependencies>
</metadata>
</package>
View
29 Simple.Data.UnitTest/BufferedEnumerableTest.cs
@@ -1,29 +0,0 @@
-using System.Collections.Generic;
-using System.Linq;
-using System.Text;
-using System.Threading;
-using NUnit.Framework;
-
-namespace Simple.Data.UnitTest
-{
- [TestFixture]
- public class BufferedEnumerableTest
- {
- [Test]
- public void ShouldCallCleanup()
- {
- // Arrange
- bool cleanedUp = false;
-
- var list = BufferedEnumerable.Create("ABC".ToIterator(), () => cleanedUp = true)
- .ToList();
-
- // Act
- Assert.AreEqual(3, list.Count);
-
- SpinWait.SpinUntil(() => cleanedUp, 1000);
-
- Assert.True(cleanedUp);
- }
- }
-}
View
1 Simple.Data.UnitTest/Simple.Data.UnitTest.csproj
@@ -71,7 +71,6 @@
<ItemGroup>
<Compile Include="AdapterFactoryTest.cs" />
<Compile Include="BinderHelperTest.cs" />
- <Compile Include="BufferedEnumerableTest.cs" />
<Compile Include="ComposerTest.cs" />
<Compile Include="ConcreteCollectionTypeCreatorTest.cs" />
<Compile Include="ConcreteTypeCreatorTest.cs" />
View
13 Simple.Data/ActionDisposable.cs
@@ -5,7 +5,7 @@
namespace Simple.Data
{
- public class ActionDisposable : IDisposable
+ public sealed class ActionDisposable : IDisposable
{
public static readonly IDisposable NoOp = new ActionDisposable();
private readonly Action _action;
@@ -19,8 +19,19 @@ public ActionDisposable(Action action)
_action = action ?? (() => { });
}
+ ~ActionDisposable()
+ {
+ Dispose(false);
+ }
+
public void Dispose()
{
+ Dispose(true);
+ GC.SuppressFinalize(this);
+ }
+
+ private void Dispose(bool disposing)
+ {
_action();
}
}
View
3 Simple.Data/Adapter.cs
@@ -150,7 +150,7 @@ protected virtual void OnSetup()
/// <param name="onError">A Func to call when there is an error. It this func returns true, carry on, otherwise abort.</param>
/// <param name="resultRequired"><c>true</c> if the result of the insert is used in code; otherwise, <c>false</c>.</param>
/// <returns>If possible, return the newly inserted rows, including any automatically-set values such as primary keys or timestamps.</returns>
- /// <remarks>This method has a default implementation based on the <see cref="Insert(string,IDictionary{string, object})"/> method.
+ /// <remarks>This method has a default implementation based on the <see cref="Insert(string,IDictionary{TKey,TValue},bool)"/> method.
/// You should override this method if your adapter can optimize the operation.</remarks>
public virtual IEnumerable<IDictionary<string, object>> InsertMany(string tableName,
IEnumerable<IDictionary<string, object>> dataList,
@@ -194,7 +194,6 @@ private void InsertManyWithoutReturn(string tableName, IEnumerable<IDictionary<s
{
foreach (var row in dataList)
{
- IDictionary<string, object> inserted;
try
{
Insert(tableName, row, false);
View
18 Simple.Data/BufferedEnumerable.cs
@@ -1,18 +0,0 @@
-using System;
-using System.Collections.Generic;
-using System.Threading.Tasks;
-
-namespace Simple.Data
-{
- public static class BufferedEnumerable
- {
- public static IEnumerable<T> Create<T>(Func<Maybe<T>> iterator, Action cleanup)
- {
- var enumerable = new BufferedEnumerable<T>();
- var task = new Task(() => enumerable.Iterate(iterator));
- task.ContinueWith(t => cleanup());
- task.Start();
- return enumerable;
- }
- }
-}
View
205 Simple.Data/BufferedEnumerable1.cs
@@ -1,205 +0,0 @@
-using System;
-using System.Collections;
-using System.Collections.Generic;
-using System.Threading;
-
-namespace Simple.Data
-{
- sealed class BufferedEnumerable<T> : IEnumerable<T>
- {
- private readonly ReaderWriterLockSlim _lock = new ReaderWriterLockSlim();
- private readonly List<T> _buffer = new List<T>();
- private bool _done;
-
- internal void Iterate(Func<Maybe<T>> iterator)
- {
- Maybe<T> maybe;
- while ((maybe = iterator()).HasValue)
- {
- Add(maybe.Value);
- }
- SetDone();
- }
-
- private void SetDone()
- {
- _lock.EnterWriteLock();
- try
- {
- _done = true;
- }
- finally
- {
- _lock.ExitWriteLock();
- }
- }
-
- private void Add(T item)
- {
- _lock.EnterWriteLock();
- try
- {
- _buffer.Add(item);
- }
- finally
- {
- _lock.ExitWriteLock();
- }
- }
-
- private T this[int index]
- {
- get
- {
- _lock.EnterReadLock();
- try
- {
- return _buffer[index];
- }
- finally
- {
- _lock.ExitReadLock();
- }
- }
- }
-
- private int Count
- {
- get
- {
- _lock.EnterReadLock();
- try
- {
- return _buffer.Count;
- }
- finally
- {
- _lock.ExitReadLock();
- }
- }
- }
-
- private bool Done
- {
- get
- {
- _lock.EnterReadLock();
- try
- {
- return _done;
- }
- finally
- {
- _lock.ExitReadLock();
- }
- }
- }
-
- class BufferedEnumerator : IEnumerator<T>
- {
- private readonly BufferedEnumerable<T> _bufferedEnumerable;
-
- public BufferedEnumerator(BufferedEnumerable<T> bufferedEnumerable)
- {
- _bufferedEnumerable = bufferedEnumerable;
- }
-
- private int _current = -1;
-
- /// <summary>
- /// Performs application-defined tasks associated with freeing, releasing, or resetting unmanaged resources.
- /// </summary>
- /// <filterpriority>2</filterpriority>
- public void Dispose()
- {
-
- }
-
- /// <summary>
- /// Advances the enumerator to the next element of the collection.
- /// </summary>
- /// <returns>
- /// true if the enumerator was successfully advanced to the next element; false if the enumerator has passed the end of the collection.
- /// </returns>
- /// <exception cref="T:System.InvalidOperationException">The collection was modified after the enumerator was created. </exception><filterpriority>2</filterpriority>
- public bool MoveNext()
- {
- ++_current;
-
- if (_bufferedEnumerable._done)
- {
- return _current < _bufferedEnumerable.Count;
- }
-
- WaitForBuffer();
- return _current < _bufferedEnumerable.Count;
- }
-
- private void WaitForBuffer()
- {
- // Block until next item delivered or iterator is done.
- SpinWait.SpinUntil(() => _bufferedEnumerable.Done || _bufferedEnumerable.Count > _current);
- }
-
- /// <summary>
- /// Sets the enumerator to its initial position, which is before the first element in the collection.
- /// </summary>
- /// <exception cref="T:System.InvalidOperationException">The collection was modified after the enumerator was created. </exception><filterpriority>2</filterpriority>
- public void Reset()
- {
- _current = -1;
- }
-
- /// <summary>
- /// Gets the element in the collection at the current position of the enumerator.
- /// </summary>
- /// <returns>
- /// The element in the collection at the current position of the enumerator.
- /// </returns>
- public T Current
- {
- get
- {
- if (_current >= _bufferedEnumerable.Count) throw new InvalidOperationException();
- return _bufferedEnumerable[_current];
- }
- }
-
- /// <summary>
- /// Gets the current element in the collection.
- /// </summary>
- /// <returns>
- /// The current element in the collection.
- /// </returns>
- /// <exception cref="T:System.InvalidOperationException">The enumerator is positioned before the first element of the collection or after the last element.</exception><filterpriority>2</filterpriority>
- object IEnumerator.Current
- {
- get { return Current; }
- }
- }
-
- /// <summary>
- /// Returns an enumerator that iterates through the collection.
- /// </summary>
- /// <returns>
- /// A <see cref="T:System.Collections.Generic.IEnumerator`1"/> that can be used to iterate through the collection.
- /// </returns>
- /// <filterpriority>1</filterpriority>
- public IEnumerator<T> GetEnumerator()
- {
- return new BufferedEnumerator(this);
- }
-
- /// <summary>
- /// Returns an enumerator that iterates through a collection.
- /// </summary>
- /// <returns>
- /// An <see cref="T:System.Collections.IEnumerator"/> object that can be used to iterate through the collection.
- /// </returns>
- /// <filterpriority>2</filterpriority>
- IEnumerator IEnumerable.GetEnumerator()
- {
- return GetEnumerator();
- }
- }
-}
View
2 Simple.Data/Commands/FindByCommand.cs
@@ -52,7 +52,7 @@ public bool IsCommandFor(string method)
}
}
- private static IDictionary<string, object> CreateCriteriaDictionary(InvokeMemberBinder binder, IList<object> args)
+ private static IEnumerable<KeyValuePair<string, object>> CreateCriteriaDictionary(InvokeMemberBinder binder, IList<object> args)
{
IDictionary<string, object> criteriaDictionary = null;
if (binder.Name.Equals("FindBy") || binder.Name.Equals("find_by"))
View
2 Simple.Data/Commands/InsertCommand.cs
@@ -51,7 +51,7 @@ private static object DoInsert(InvokeMemberBinder binder, object[] args, DataStr
return InsertDictionary(binder, args, dataStrategy, tableName);
}
- private static object InsertDictionary(InvokeMemberBinder binder, object[] args, DataStrategy dataStrategy, string tableName)
+ private static object InsertDictionary(InvokeMemberBinder binder, IEnumerable<object> args, DataStrategy dataStrategy, string tableName)
{
return dataStrategy.Insert(tableName, binder.NamedArgumentsToDictionary(args), !binder.IsResultDiscarded());
}
View
2 Simple.Data/Commands/UpdateByCommand.cs
@@ -59,7 +59,7 @@ internal static object UpdateByKeyFields(string tableName, DataStrategy dataStra
foreach (var keyFieldName in keyFieldNames)
{
var name = keyFieldName;
- var keyValuePair = record.Where(kvp => kvp.Key.Homogenize().Equals(name.Homogenize())).SingleOrDefault();
+ var keyValuePair = record.SingleOrDefault(kvp => kvp.Key.Homogenize().Equals(name.Homogenize()));
if (string.IsNullOrWhiteSpace(keyValuePair.Key))
{
throw new InvalidOperationException("Key field value not set.");
View
2 Simple.Data/DictionaryCloner.cs
@@ -38,7 +38,7 @@ public class DictionaryCloner
return clone;
}
- private void CopyDictionaryAndCloneNestedDictionaries(IDictionary<string, object> dictionary, IDictionary<string, object> clone)
+ private void CopyDictionaryAndCloneNestedDictionaries(IEnumerable<KeyValuePair<string, object>> dictionary, IDictionary<string, object> clone)
{
foreach (var keyValuePair in dictionary)
{
View
2 Simple.Data/FunctionSignature.cs
@@ -98,7 +98,7 @@ public bool Equals(Parameter other)
{
if (ReferenceEquals(null, other)) return false;
if (ReferenceEquals(this, other)) return true;
- return Equals(other._type, _type) && Equals(other._name, _name) && other._size == _size;
+ return other._type == _type && Equals(other._name, _name) && other._size == _size;
}
public override bool Equals(object obj)
View
10 Simple.Data/InMemoryAdapter.cs
@@ -80,7 +80,7 @@ public override IList<string> GetKeyNames(string tableName)
object nextVal = 0;
if(table.Count > 0)
{
- nextVal = table.Select(d => d[autoIncrementColumn]).Max(); ;
+ nextVal = table.Select(d => d[autoIncrementColumn]).Max();
}
nextVal = ObjectMaths.Increment(nextVal);
@@ -152,7 +152,7 @@ public override int Update(string tableName, IDictionary<string, object> data, S
return count;
}
- private static void UpdateRecord(IDictionary<string, object> data, IDictionary<string, object> record)
+ private static void UpdateRecord(IEnumerable<KeyValuePair<string, object>> data, IDictionary<string, object> record)
{
foreach (var kvp in data)
{
@@ -270,17 +270,17 @@ public string MasterTableName
}
}
- public IDictionary<string, object> Upsert(string tableName, IDictionary<string, object> dict, SimpleExpression criteriaExpression, bool isResultRequired, IAdapterTransaction adapterTransaction)
+ public override IDictionary<string, object> Upsert(string tableName, IDictionary<string, object> dict, SimpleExpression criteriaExpression, bool isResultRequired, IAdapterTransaction adapterTransaction)
{
return Upsert(tableName, dict, criteriaExpression, isResultRequired);
}
- public IEnumerable<IDictionary<string, object>> UpsertMany(string tableName, IList<IDictionary<string, object>> list, IEnumerable<string> keyFieldNames, IAdapterTransaction adapterTransaction, bool isResultRequired, Func<IDictionary<string,object>,Exception,bool> errorCallback)
+ public override IEnumerable<IDictionary<string, object>> UpsertMany(string tableName, IList<IDictionary<string, object>> list, IEnumerable<string> keyFieldNames, IAdapterTransaction adapterTransaction, bool isResultRequired, Func<IDictionary<string,object>,Exception,bool> errorCallback)
{
return UpsertMany(tableName, list, keyFieldNames, isResultRequired, errorCallback);
}
- public IEnumerable<IDictionary<string, object>> UpsertMany(string tableName, IList<IDictionary<string, object>> list, IAdapterTransaction adapterTransaction, bool isResultRequired, Func<IDictionary<string, object>, Exception, bool> errorCallback)
+ public override IEnumerable<IDictionary<string, object>> UpsertMany(string tableName, IList<IDictionary<string, object>> list, IAdapterTransaction adapterTransaction, bool isResultRequired, Func<IDictionary<string, object>, Exception, bool> errorCallback)
{
return UpsertMany(tableName, list, isResultRequired, errorCallback);
}
View
2 Simple.Data/MethodNameParser.cs
@@ -65,7 +65,7 @@ internal static string RemoveCommandPart(string methodName)
{
if (methodName == null) throw new ArgumentNullException("methodName");
if (!methodName.Contains("By")) return methodName;
- return methodName.Substring(methodName.IndexOf("By") + 2);
+ return methodName.Substring(methodName.IndexOf("By", StringComparison.Ordinal) + 2);
}
internal static IList<string> GetColumns(string methodName)
View
3 Simple.Data/PropertySetterBuilder.cs
@@ -174,7 +174,6 @@ private BinaryExpression CreateComplexAssign()
private TryExpression CreateTrySimpleAssign()
{
- Expression assign;
var changeTypeMethod = typeof (PropertySetterBuilder).GetMethod("SafeConvert",
BindingFlags.Static | BindingFlags.NonPublic);
@@ -195,7 +194,7 @@ private TryExpression CreateTrySimpleAssign()
Expression.Constant(_property.PropertyType));
}
- assign = Expression.Assign(_nameProperty, Expression.Convert(callConvert, _property.PropertyType));
+ var assign = Expression.Assign(_nameProperty, Expression.Convert(callConvert, _property.PropertyType));
if (_property.PropertyType.IsEnum)
{
return Expression.TryCatch( // try {
View
162 Simple.Data/QueryPolyfills/HavingClauseHandler.cs
@@ -1,162 +0,0 @@
-using System;
-using System.Collections;
-using System.Collections.Generic;
-using System.Linq;
-using System.Text.RegularExpressions;
-
-namespace Simple.Data.QueryPolyfills
-{
- internal class HavingClauseHandler
- {
- private readonly Dictionary<SimpleExpressionType, Func<SimpleExpression, Func<IDictionary<string, object>, bool>>> _expressionFormatters;
-
- private readonly WhereClause _whereClause;
-
- public HavingClauseHandler(WhereClause whereClause)
- {
- _whereClause = whereClause;
- _expressionFormatters = new Dictionary<SimpleExpressionType, Func<SimpleExpression, Func<IDictionary<string,object>, bool>>>
- {
- {SimpleExpressionType.And, LogicalExpressionToWhereClause},
- {SimpleExpressionType.Or, LogicalExpressionToWhereClause},
- {SimpleExpressionType.Equal, EqualExpressionToWhereClause},
- {SimpleExpressionType.NotEqual, NotEqualExpressionToWhereClause},
- {SimpleExpressionType.Function, FunctionExpressionToWhereClause},
- {SimpleExpressionType.GreaterThan, GreaterThanToWhereClause},
- {SimpleExpressionType.LessThan, LessThanToWhereClause},
- {SimpleExpressionType.GreaterThanOrEqual, GreaterThanOrEqualToWhereClause},
- {SimpleExpressionType.LessThanOrEqual, LessThanOrEqualToWhereClause},
- {SimpleExpressionType.Empty, expr => _ => true },
- };
- }
-
- private Func<IDictionary<string, object>, bool> FunctionExpressionToWhereClause(SimpleExpression arg)
- {
- var key = GetKeyFromLeftOperand(arg);
- var function = arg.RightOperand as SimpleFunction;
- if (ReferenceEquals(function, null)) throw new InvalidOperationException("Expression type of function but no function supplied.");
- if (function.Name.Equals("like", StringComparison.OrdinalIgnoreCase))
- {
- var pattern = function.Args[0].ToString();
- if (pattern.Contains("%") || pattern.Contains("_")) // SQL Server LIKE
- {
- pattern = pattern.Replace("%", ".*").Replace('_', '.');
- }
-
- var regex = new Regex("^" + pattern + "$", RegexOptions.Multiline | RegexOptions.IgnoreCase);
-
- return d => d.ContainsKey(key) && (!ReferenceEquals(d[key], null)) && regex.IsMatch(d[key].ToString());
- }
-
- throw new NotSupportedException("Expression Function not supported.");
- }
-
- private Func<IDictionary<string, object>, bool> GreaterThanToWhereClause(SimpleExpression arg)
- {
- var key = GetKeyFromLeftOperand(arg);
-
- return d => d.ContainsKey(key) && !ReferenceEquals(d[key], null) && ((IComparable)d[key]).CompareTo(arg.RightOperand) > 0;
- }
-
- private Func<IDictionary<string, object>, bool> LessThanToWhereClause(SimpleExpression arg)
- {
- var key = GetKeyFromLeftOperand(arg);
-
- return d => d.ContainsKey(key) && !ReferenceEquals(d[key], null) && ((IComparable)d[key]).CompareTo(arg.RightOperand) < 0;
- }
-
- private Func<IDictionary<string, object>, bool> GreaterThanOrEqualToWhereClause(SimpleExpression arg)
- {
- var key = GetKeyFromLeftOperand(arg);
-
- return d => d.ContainsKey(key) && !ReferenceEquals(d[key], null) && ((IComparable)d[key]).CompareTo(arg.RightOperand) >= 0;
- }
-
- private Func<IDictionary<string, object>, bool> LessThanOrEqualToWhereClause(SimpleExpression arg)
- {
- var key = GetKeyFromLeftOperand(arg);
-
- return d => d.ContainsKey(key) && !ReferenceEquals(d[key], null) && ((IComparable)d[key]).CompareTo(arg.RightOperand) <= 0;
- }
-
- private Func<IDictionary<string, object>, bool> NotEqualExpressionToWhereClause(SimpleExpression arg)
- {
- var key = GetKeyFromLeftOperand(arg);
-
- if (ReferenceEquals(arg.RightOperand, null))
- {
- return d => d.ContainsKey(key) && d[key] != null;
- }
-
- if (arg.RightOperand.GetType().IsArray)
- {
- return
- d =>
- d.ContainsKey(key) &&
- !((IEnumerable)d[key]).Cast<object>().SequenceEqual(((IEnumerable)arg.RightOperand).Cast<object>());
- }
-
- return d => d.ContainsKey(key) && !Equals(d[key], arg.RightOperand);
- }
-
- private Func<IDictionary<string, object>, bool> EqualExpressionToWhereClause(SimpleExpression arg)
- {
- var key = GetKeyFromLeftOperand(arg);
-
- if (ReferenceEquals(arg.RightOperand, null))
- {
- return d => (!d.ContainsKey(key)) || d[key] == null;
- }
-
- if (arg.RightOperand.GetType().IsArray)
- {
- return
- d =>
- d.ContainsKey(key) &&
- ((IEnumerable) d[key]).Cast<object>().SequenceEqual(((IEnumerable) arg.RightOperand).Cast<object>());
- }
-
- return d => d.ContainsKey(key) && Equals(d[key], arg.RightOperand);
- }
-
- private static string GetKeyFromLeftOperand(SimpleExpression arg)
- {
- var reference = arg.LeftOperand as ObjectReference;
-
- if (reference.IsNull()) throw new NotSupportedException("Only ObjectReference types are supported.");
-
- var key = reference.GetName();
- return key;
- }
-
- private Func<IDictionary<string,object>, bool> Format(SimpleExpression expression)
- {
- Func<SimpleExpression, Func<IDictionary<string,object>,bool>> formatter;
-
- if (_expressionFormatters.TryGetValue(expression.Type, out formatter))
- {
- return formatter(expression);
- }
-
- return _ => true;
- }
-
- private Func<IDictionary<string, object>, bool> LogicalExpressionToWhereClause(SimpleExpression arg)
- {
- var left = Format((SimpleExpression) arg.LeftOperand);
- var right = Format((SimpleExpression) arg.RightOperand);
-
- if (arg.Type == SimpleExpressionType.Or)
- {
- return d => (left(d) || right(d));
- }
- return d => (left(d) && right(d));
- }
-
- public IEnumerable<IDictionary<string, object>> Run(IEnumerable<IDictionary<string, object>> source)
- {
- var predicate = Format(_whereClause.Criteria);
- return source.Where(predicate);
- }
- }
-}
View
3 Simple.Data/Simple.Data.csproj
@@ -56,8 +56,6 @@
<Compile Include="AdapterWithFunctionsExtensions.cs" />
<Compile Include="AllColumnsSpecialReference.cs" />
<Compile Include="BinderHelper.cs" />
- <Compile Include="BufferedEnumerable.cs" />
- <Compile Include="BufferedEnumerable1.cs" />
<Compile Include="CachingAdapterFactory.cs" />
<Compile Include="CastEnumerable.cs" />
<Compile Include="Commands\CommandFactory.cs" />
@@ -117,7 +115,6 @@
<Compile Include="QueryPolyfills\FunctionHandlers.cs" />
<Compile Include="QueryPolyfills\FunctionValueResolver.cs" />
<Compile Include="QueryPolyfills\GroupingHandler.cs" />
- <Compile Include="QueryPolyfills\HavingClauseHandler.cs" />
<Compile Include="QueryPolyfills\ObjectMaths.cs" />
<Compile Include="QueryPolyfills\ObjectValueResolver.cs" />
<Compile Include="QueryPolyfills\OrderByClauseHandler.cs" />
View
2 Simple.Data/Simple.Data.nuspec
@@ -2,7 +2,7 @@
<package xmlns="http://schemas.microsoft.com/packaging/2010/07/nuspec.xsd">
<metadata>
<id>Simple.Data.Core</id>
- <version>1.0.0-beta3</version>
+ <version>1.0.0-beta4</version>
<authors>Mark Rendle</authors>
<owners>Mark Rendle</owners>
<licenseUrl>http://www.opensource.org/licenses/mit-license.php</licenseUrl>
View
2 Simple.Data/SimpleFunction.cs
@@ -22,7 +22,7 @@ public ReadOnlyCollection<object> Args
get { return _args; }
}
- public SimpleFunction(string name, object[] args)
+ public SimpleFunction(string name, IEnumerable<object> args)
{
_name = name;
_args = args.ToList().AsReadOnly();
View
1 Simple_Data.ndproj
@@ -10,6 +10,7 @@
<Name>System</Name>
<Name>System.ComponentModel.Composition</Name>
<Name>Microsoft.CSharp</Name>
+ <Name>System.Configuration</Name>
</FrameworkAssemblies>
<Dirs>
<Dir>C:\Windows\Microsoft.NET\Framework\v4.0.30319</Dir>

0 comments on commit be2bb27

Please sign in to comment.