Select query raise IndexOutOfRangeException and CorruptedException

May 26, 2013 at 8:56 AM
Edited May 26, 2013 at 8:56 AM
Hi, when query for all entries of an object type the ODB manager raises an IndexOutOfRangeException.

This is the available stack trace
   in NDatabase.IO.MultiBufferedFileIO.ReadByte() in c:\TeamCity\Agents\A\BuildAgent\work\9a4cd5884b729548\src\IO\MultiBufferedFileIO.cs:riga 164
and this is the call that raises the exception:
IObjectSet<NdbReminder> q = odb.QueryAndExecute<NdbReminder>();
Another strange behaviour that sometimes happens is that the query to get a single object by a constrain raises a CorruptedException with description: object with OID (number) has been marked as deleted, but the object is in the database as I can retrieve it with a query that returns all the objects. The code that raises the exception is the following:
var query = odb.Query<NdbClient>();

query.Descend("ID").Constrain(id).Equal();

var client = query.Execute<NdbClient>();
The object NdbClient has and int attribute ID and strings to store name, surname and other info related to a client. The id parameter for the constrain method is a simple int parameter of the method that executes the call to the database

Thanks, Alessio
Jun 10, 2013 at 7:22 AM
Maybe you can try List<NdbReminder> q=odb.AsQueryable<NdbReminder>().ToList();

And Maybe you can use the following code to instead "ID" Field, because NDatabase already have id itself.

public NDatabase.Api.OID ObjectID
{
get
{
  NDatabase.Api.OID id = null;
  try
  {
     id = odb.GetObjectId<NdbClient>(this);
  }
  catch (Exception)
  {
     odb.store(this); // If object not store will arise exception
     try
     {
        id = odb.GetObjectId<NdbClient>(this);                    }
     }
     catch (Exception){ }
     return id;
   }
}
}
public long id { get { return ObjectID== null ? 0 : ObjectID.ObjectId; } }
public static NdbClient GetByID(long id) { return odb.GetObjectFromId(NDatabase.OIDFactory.BuildObjectOID(id)) as NdbClient ; }
Jun 10, 2013 at 7:29 AM
Thanks, I'll try,

Alessio