Skip to content

Commit

Permalink
added a slice operator
Browse files Browse the repository at this point in the history
  • Loading branch information
Andrew Theken committed Jul 22, 2010
1 parent 24f5813 commit 4190638
Show file tree
Hide file tree
Showing 4 changed files with 47 additions and 1 deletion.
2 changes: 1 addition & 1 deletion NoRM.Tests/CollectionUpdateTests/UpdateTests.cs
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ namespace Norm.Tests
{
public class UpdateTests : IDisposable
{
private readonly Mongo _server;
private readonly IMongo _server;
private readonly IMongoCollection<CheeseClubContact> _collection;
public UpdateTests()
{
Expand Down
19 changes: 19 additions & 0 deletions NoRM/Commands/Qualifiers/Q.cs
Original file line number Diff line number Diff line change
Expand Up @@ -47,6 +47,25 @@ public static Expando And(this QualifierCommand baseCommand, params QualifierCom
return retval;
}

/// <summary>
/// Produces a single element $slice at the specific index.
/// </summary>
/// <param name="index">The single index that the slice will be used with.</param>
public static SliceQualifier Slice(int index)
{
return new SliceQualifier(index);
}

/// <summary>
/// Produces a $slice qualifier at starting at the left index and going to the right index.
/// </summary>
/// <param name="left">The first index for the slice.</param>
/// <param name="right">The second index for the slice.</param>
public static SliceQualifier Slice(int left,int right)
{
return new SliceQualifier(left,right);
}

/// <summary>
/// construct a $where qualifier
/// </summary>
Expand Down
26 changes: 26 additions & 0 deletions NoRM/Commands/Qualifiers/SliceQualifier.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using Norm.BSON;

namespace Norm.Commands.Qualifiers
{
/// <summary>
/// A command that can be used as request.
/// </summary>
public class SliceQualifier : QualifierCommand
{
public SliceQualifier(int index)
: this(index, index)
{

}

public SliceQualifier(int left, int right)
: base("$slice", new int[] { left, right })
{

}
}
}
1 change: 1 addition & 0 deletions NoRM/NoRM.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -134,6 +134,7 @@
<Compile Include="Commands\Qualifiers\NotInQualifier.cs" />
<Compile Include="Commands\Qualifiers\SizeQualifier.cs" />
<Compile Include="BSON\Expando.cs" />
<Compile Include="Commands\Qualifiers\SliceQualifier.cs" />
<Compile Include="Commands\Qualifiers\WhereQualifier.cs" />
<Compile Include="Configuration\ConfigurationContainer.cs" />
<Compile Include="Configuration\IConfigurationContainer.cs" />
Expand Down

0 comments on commit 4190638

Please sign in to comment.