91 lines
2.1 KiB
C#
91 lines
2.1 KiB
C#
// /**
|
|
// * File: Program.cs
|
|
// * Author: haraldwolff
|
|
// *
|
|
// * This file and it's content is copyrighted by the Author and / or copyright holder.
|
|
// * Any use wihtout proper permission is illegal and may lead to legal actions.
|
|
// *
|
|
// *
|
|
// **/
|
|
using System;
|
|
using ln.types.odb.ng.storage;
|
|
using ln.types.odb.ng;
|
|
using ln.logging;
|
|
using System.Linq;
|
|
|
|
namespace ln.types.test
|
|
{
|
|
class MainClass
|
|
{
|
|
public static void Main(string[] args)
|
|
{
|
|
Logger.ConsoleLogger.MaxLogLevel = LogLevel.DEBUGDETAIL;
|
|
Logging.Log(LogLevel.DEBUG, "ln.types.odb.ng test suite");
|
|
|
|
using (IStorageContainer container = new Session(new FSStorageContainer(".")))
|
|
{
|
|
container.Open();
|
|
|
|
IStorage storage = container.GetStorage("test");
|
|
|
|
if (!storage.IsOpen)
|
|
storage.Open();
|
|
|
|
foreach (Guid documentID in storage.GetDocumentIDs())
|
|
{
|
|
Logging.Log(LogLevel.INFO, "DocumentID: {0}", documentID);
|
|
Document doc = storage.Load(documentID);
|
|
Logging.Log(LogLevel.INFO, doc.ToString());
|
|
doc["FeldC"] = doc["FeldC"].AsLong + 1;
|
|
storage.Save(doc);
|
|
}
|
|
|
|
Document document = new Document();
|
|
|
|
document["FeldA"] = "Ich bin das Feld A";
|
|
document["FeldB"] = "Ich bin das Feld B";
|
|
document["FeldC"] = new Random().Next();
|
|
|
|
storage.Save(document);
|
|
storage.Save(document);
|
|
|
|
ODBMapper mapper = new ODBMapper(container);
|
|
|
|
foreach (MapableClass mapableClass in mapper.GetDocumentIDs<MapableClass>().Select((id)=>mapper.Load<MapableClass>(id)))
|
|
{
|
|
Logging.Log(LogLevel.INFO, "mapper found: {0}",mapableClass);
|
|
mapableClass.ANumber++;
|
|
mapper.Save(mapableClass);
|
|
}
|
|
|
|
MapableClass mapable = new MapableClass();
|
|
mapper.Save<MapableClass>(mapable);
|
|
|
|
|
|
storage.Close();
|
|
container.Close();
|
|
}
|
|
}
|
|
}
|
|
|
|
class MapableClass
|
|
{
|
|
public int ANumber { get; set; }
|
|
public String MyString;
|
|
|
|
public MapableClass()
|
|
{
|
|
ANumber = new Random().Next();
|
|
MyString = ANumber.ToString();
|
|
}
|
|
|
|
public override string ToString()
|
|
{
|
|
return String.Format("[MapableClass ANumber={0} MyString={1}]",ANumber,MyString);
|
|
}
|
|
|
|
|
|
}
|
|
|
|
}
|