C# Class JPB.DataAccess.Helper.LocalDb.LocalDbManager

Mostra file Open project: JPVenson/DataAccess Class Usage Examples

Private Properties

Property Type Description
AddMapping void
AddTable void
GetMappings IEnumerable
LocalDbManager System
OnSetupDone void

Public Methods

Method Description
Alter ( ) : EditDatabaseScope

allowes to Add or remove tabels from this Database. If you try to use the tables before calling dispose on the returned Scope an InvalidOperationException will be thrown

GetSerializableContent ( ) : DataContent

Creates a new Class that supportes the IXmlSerializable interface. It is linked to this database and can be used to read or write all content in this database. To Write all elements using (var memStream = new MemoryStream()) { new XmlSerializer(typeof(DataContent)).Serialize(memStream, LocalDbManager.Scope.GetSerializableContent()); var xml = Encoding.ASCII.GetString(memStream.ToArray()); } When reading the data the database creation has to be in progress. You must execute the statement inside the DatabaseScope you want to fill using (new DatabaseScope()) { //Table creation ... //new LocalDbReposetory<T>(new DbConfig()) using (var memStream = new MemoryStream(Encoding.ASCII.GetBytes("xml"))) { new XmlSerializer(typeof(DataContent)).Deserialize(memStream); } }

Private Methods

Method Description
AddMapping ( Type source, Type target ) : void
AddTable ( ILocalDbReposetoryBaseInternalUsage repro ) : void
GetMappings ( Type thisType ) : IEnumerable
LocalDbManager ( ) : System
OnSetupDone ( ) : void

Method Details

Alter() public method

allowes to Add or remove tabels from this Database. If you try to use the tables before calling dispose on the returned Scope an InvalidOperationException will be thrown
public Alter ( ) : EditDatabaseScope
return EditDatabaseScope

GetSerializableContent() public method

Creates a new Class that supportes the IXmlSerializable interface. It is linked to this database and can be used to read or write all content in this database. To Write all elements using (var memStream = new MemoryStream()) { new XmlSerializer(typeof(DataContent)).Serialize(memStream, LocalDbManager.Scope.GetSerializableContent()); var xml = Encoding.ASCII.GetString(memStream.ToArray()); } When reading the data the database creation has to be in progress. You must execute the statement inside the DatabaseScope you want to fill using (new DatabaseScope()) { //Table creation ... //new LocalDbReposetory<T>(new DbConfig()) using (var memStream = new MemoryStream(Encoding.ASCII.GetBytes("xml"))) { new XmlSerializer(typeof(DataContent)).Deserialize(memStream); } }
public GetSerializableContent ( ) : DataContent
return DataContent