Skip to content

Commit

Permalink
Updated delete syntax
Browse files Browse the repository at this point in the history
  • Loading branch information
jasondentler committed Feb 18, 2011
1 parent 30bb2e4 commit 235e7a2
Show file tree
Hide file tree
Showing 4 changed files with 46 additions and 14 deletions.
1 change: 1 addition & 0 deletions src/FluentDML/FluentDML.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,7 @@
<Reference Include="System.Xml" />
</ItemGroup>
<ItemGroup>
<Compile Include="IDeleteWhere.cs" />
<Compile Include="SyntaxExample.cs" />
<Compile Include="IUpsertSet.cs" />
<Compile Include="IDelete.cs" />
Expand Down
2 changes: 1 addition & 1 deletion src/FluentDML/IDelete.cs
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ namespace FluentDML
public interface IDelete<T>
{

IDbCommand Where(Expression<Func<T, bool>> predicate);
IDeleteWhere<T> Where(Expression<Func<T, bool>> predicate);

}
}
14 changes: 14 additions & 0 deletions src/FluentDML/IDeleteWhere.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
using System;
using System.Data;
using System.Linq.Expressions;

namespace FluentDML
{
public interface IDeleteWhere<T>
{

IDeleteWhere<T> And(Expression<Func<T, bool>> predicate);
IDbCommand ToCommand();

}
}
43 changes: 30 additions & 13 deletions src/FluentDML/SyntaxExample.cs
Original file line number Diff line number Diff line change
Expand Up @@ -2,32 +2,39 @@

namespace FluentDML
{
class SyntaxExample
internal class SyntaxExample
{

public SyntaxExample()
{
Update<SyntaxExample>()

var evnt = new SomeEvent();

Update<SomeViewModel>()
.Set(c => c.Value1, "name")
.Set(c => c.Value2, 1)
.Where(c => c.Id == new Guid())
.And(c => c.Value2 == 1);
.And(c => c.Value2 == 1)
.ToCommand();

Update<SyntaxExample>()
.MapFrom(new object())
Update<SomeViewModel>()
.MapFrom(evnt)
.WithId(c => c.Id);

Upsert<SyntaxExample>()
Upsert<SomeViewModel>()
.Set(c => c.Value1, "name")
.Set(c => c.Value2, 1)
.WithId(c => c.Id);

Upsert<SyntaxExample>()
.MapFrom(new object())
Upsert<SomeViewModel>()
.MapFrom(evnt)
.WithId(c => c.Id);

Delete<SyntaxExample>()
.Where(c => c.Id == new Guid());
Delete<SomeViewModel>()
.Where(c => c.Id == new Guid())
.And(c => c.Value2 == 1)
.ToCommand();

}

public IDelete<T> Delete<T>()
Expand All @@ -45,10 +52,20 @@ public IUpdate<T> Update<T>()
throw new NotImplementedException();
}

public string Value1 { get; set; }
public int Value2 { get; set; }
protected class SomeViewModel
{
public Guid Id { get; set; }
public string Value1 { get; set; }
public int Value2 { get; set; }
}

protected class SomeEvent
{
public Guid Id { get; set; }
public string Value1 { get; set; }
public int Value2 { get; set; }
}

public Guid Id { get; set; }

}
}

0 comments on commit 235e7a2

Please sign in to comment.