Permalink
Browse files

Made the sample easier to use and added IDisposable

  • Loading branch information...
1 parent e11bdc2 commit e233cced6576a66c58f808fd7315b1ad4237b3be @dmohl committed May 24, 2011
View
@@ -24,22 +24,16 @@
member x.Samples with get() = x.samples and set(v) = x.samples <- v
// Add a new DbSet for each entity that should be persisted to the data store
-type IRepository<'a> =
- abstract Add : 'a -> unit
- abstract Delete : 'a -> unit
- abstract GetAll : unit -> seq<'a>
- abstract GetById : 'b -> 'a
- abstract Save : unit -> unit
-
type SampleRepository() =
let context = new MyApplicationEntities()
- interface IRepository<ASample> with
- member x.GetAll() = context.Samples |> Seq.cast
- member x.GetById id = context.Samples.Find(id)
- member x.Add item =
- context.Samples.Add item |> ignore
- member x.Delete id =
- context.Samples.Find(id)
- |> context.Samples.Remove
- |> ignore
- member x.Save() = context.SaveChanges() |> ignore
+ member x.GetAll() = context.Samples |> Seq.cast
+ member x.GetById id = context.Samples.Find(id)
+ member x.Add item =
+ context.Samples.Add item |> ignore
+ member x.Delete id =
+ context.Samples.Find(id)
+ |> context.Samples.Remove
+ |> ignore
+ member x.Save() = context.SaveChanges() |> ignore
+ interface IDisposable with
+ member x.Dispose() = context.Dispose()
View
Binary file not shown.
View
Binary file not shown.
View
@@ -2,7 +2,7 @@
<package xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xsd="http://www.w3.org/2001/XMLSchema">
<metadata xmlns="http://schemas.microsoft.com/packaging/2010/07/nuspec.xsd">
<id>FSRepository</id>
- <version>1.0.0.0</version>
+ <version>2.0.0.0</version>
<dependencies>
<dependency id="EntityFramework" version="[4.1.10331.0, 5.0.0.0)" />
</dependencies>

0 comments on commit e233cce

Please sign in to comment.