Skip to main content

PocoDataSource<T>

Provide a thread-safe CRUD wrapper around a collection of POCOs

Assembly: ServiceStack.dll
View Source
Declaration
public class PocoDataSource<T>

Methods

NextId()

Return next Id in sequence

View Source
Declaration
public long NextId()
Returns

System.Int64

GetAll()

Returns a shallow copy of all items

View Source
Declaration
public List<T> GetAll()
Returns

System.Collections.Generic.List<<T>>

ToDataSource(IQueryData, IRequest)

Create and return all items in a MemoryDataSource

View Source
Declaration
public MemoryDataSource<T> ToDataSource(IQueryData dto, IRequest req)
Returns

ServiceStack.MemoryDataSource<T>

Parameters
TypeName
ServiceStack.IQueryDatadto
ServiceStack.Web.IRequestreq

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
Declaration
public T Add(T item)
Returns

<T>

Parameters
TypeName
<T>item

TryUpdate(T)

Replace Item

View Source
Declaration
public bool TryUpdate(T item)
Returns

System.Boolean

Parameters
TypeName
<T>item

TryUpdateById(T, Object)

Replace existing Item with same Id

View Source
Declaration
public bool TryUpdateById(T item, object itemId)
Returns

System.Boolean: true if an existing item was found and replaced otherwise false

Parameters
TypeName
<T>item
System.ObjectitemId

TryDelete(T)

Delete Item by Poco

View Source
Declaration
public bool TryDelete(T item)
Returns

System.Boolean: true if an item was deleted otherwise false

Parameters
TypeName
<T>item

TryDeleteById(Object)

Delete Item with same Id

View Source
Declaration
public bool TryDeleteById(object itemId)
Returns

System.Boolean: true if an item was deleted otherwise false

Parameters
TypeName
System.ObjectitemId

TryDeleteByIds<TId>(IEnumerable<TId>)

Delete All Item with matching Ids

View Source
Declaration
public int TryDeleteByIds<TId>(IEnumerable<TId> itemIds)
Returns

System.Int32: true if an item was deleted otherwise false

Parameters
TypeName
System.Collections.Generic.IEnumerable<<TId>>itemIds
Type Parameters
  • TId

Save(T)

Add or Update existing Item if item with same Id exists

View Source
Declaration
public T Save(T item)
Returns

<T>

Parameters
TypeName
<T>item