PocoDataSource<T>
Provide a thread-safe CRUD wrapper around a collection of POCOs
Assembly: ServiceStack.dll
View Source
public class PocoDataSource<T>
Methods
NextId()
Return next Id in sequence
View Source
public long NextId()
Returns
System.Int64
GetAll()
Returns a shallow copy of all items
View Source
public List<T> GetAll()
Returns
System.Collections.Generic.List<<T>>
ToDataSource(IQueryData, IRequest)
Create and return all items in a MemoryDataSource
View Source
public MemoryDataSource<T> ToDataSource(IQueryData dto, IRequest req)
Returns
ServiceStack.MemoryDataSource<T>
Parameters
Type | Name |
---|---|
ServiceStack.IQueryData | dto |
ServiceStack.Web.IRequest | req |
Add(T)
Add an existing item. Use NextId() to populate Item with Unique Id Use Save() to Replace existing Item with same Id when it exists
View Source
public T Add(T item)
Returns
<T>
Parameters
Type | Name |
---|---|
<T> | item |
TryUpdate(T)
Replace Item
View Source
public bool TryUpdate(T item)
Returns
System.Boolean
Parameters
Type | Name |
---|---|
<T> | item |
TryUpdateById(T, Object)
Replace existing Item with same Id
View Source
public bool TryUpdateById(T item, object itemId)
Returns
System.Boolean
: true if an existing item was found and replaced otherwise false
Parameters
Type | Name |
---|---|
<T> | item |
System.Object | itemId |
TryDelete(T)
Delete Item by Poco
View Source
public bool TryDelete(T item)
Returns
System.Boolean
: true if an item was deleted otherwise false
Parameters
Type | Name |
---|---|
<T> | item |
TryDeleteById(Object)
Delete Item with same Id
View Source
public bool TryDeleteById(object itemId)
Returns
System.Boolean
: true if an item was deleted otherwise false
Parameters
Type | Name |
---|---|
System.Object | itemId |
TryDeleteByIds<TId>(IEnumerable<TId>)
Delete All Item with matching Ids
View Source
public int TryDeleteByIds<TId>(IEnumerable<TId> itemIds)
Returns
System.Int32
: true if an item was deleted otherwise false
Parameters
Type | Name |
---|---|
System.Collections.Generic.IEnumerable<<TId>> | itemIds |
Type Parameters
TId
Save(T)
Add or Update existing Item if item with same Id exists
View Source
public T Save(T item)
Returns
<T>
Parameters
Type | Name |
---|---|
<T> | item |