Coder Social home page Coder Social logo

lex.db's People

Contributors

bartlannoeye avatar bryant1410 avatar demigor avatar lokimidgard avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

lex.db's Issues

Throwing exception very often on Windows phone 8

I'm getting huge amount of exceptions randomly on WP8. It's happening during lot of parallel calls to DbTable.SaveAsync and DbTable.LoadByKeyAsync.

There are basically three kinds of them:

System.InvalidOperationException: Nested write transaction inside read only one
   at Lex.Db.DbInstance.WriteScope()
   at Lex.Db.DbTable`1.WriteScope(Boolean autoReload)
   at Lex.Db.DbTable`1.Save(T item)
   at Lex.Db.DbTableAsync.<>c__DisplayClass22`1.<SaveAsync>b__21()
   at System.Threading.Tasks.Task.InnerInvoke()
   at System.Threading.Tasks.Task.Execute()



System.MethodAccessException: Attempt by method 'System.Threading.ReaderWriterLockSlim.WaitOnEvent(System.Threading.EventWaitHandle, UInt32 ByRef, TimeoutTracker)' to access method 'System.Threading.WaitHandle.WaitOne(Int32, Boolean)' failed.
   at System.Threading.ReaderWriterLockSlim.WaitOnEvent(EventWaitHandle waitEvent, UInt32& numWaiters, TimeoutTracker timeout)
   at System.Threading.ReaderWriterLockSlim.TryEnterWriteLockCore(TimeoutTracker timeout)
   at System.Threading.ReaderWriterLockSlim.EnterWriteLock()
   at Lex.Db.IsolatedStorage.DbTableStorage.BeginWrite()
   at Lex.Db.DbInstance.BulkWriteScope.GetWriter(DbTable table, Boolean autoReload)
   at Lex.Db.DbTable`1.WriteScope(Boolean autoReload)
   at Lex.Db.DbTable`1.Save(T item)
   at Lex.Db.DbTableAsync.<>c__DisplayClass22`1.<SaveAsync>b__21()
   at System.Threading.Tasks.Task.InnerInvoke()
   at System.Threading.Tasks.Task.Execute()



System.MethodAccessException: Attempt by method 'System.Threading.ReaderWriterLockSlim.WaitOnEvent(System.Threading.EventWaitHandle, UInt32 ByRef, TimeoutTracker)' to access method 'System.Threading.WaitHandle.WaitOne(Int32, Boolean)' failed.
   at System.Threading.ReaderWriterLockSlim.WaitOnEvent(EventWaitHandle waitEvent, UInt32& numWaiters, TimeoutTracker timeout)
   at System.Threading.ReaderWriterLockSlim.TryEnterWriteLockCore(TimeoutTracker timeout)
   at System.Threading.ReaderWriterLockSlim.EnterWriteLock()
   at Lex.Db.IsolatedStorage.DbTableStorage.BeginWrite()
   at Lex.Db.DbInstance.BulkWriteScope.GetWriter(DbTable table, Boolean autoReload)
   at Lex.Db.DbInstance.BulkWriteScope.GetReader(DbTable table)
   at Lex.Db.DbTable`1.ReadScope()
   at Lex.Db.DbTable`1.LoadByKey[K](K key)
   at Lex.Db.DbTableAsync.<>c__DisplayClassd`2.<LoadByKeyAsync>b__c()
   at System.Threading.Tasks.Task`1.InnerInvoke()
   at System.Threading.Tasks.Task.Execute()

Publish XML comments with NuGet

Please, enable "XML documentation file" in project Build options and include this xml files in NuGet package so XML comment were available within IntelliSense.

System.Reflection.TargetException after upgrading to v 1.2.6

Everything was running fine in v 1.2.5, after upgrading to v 1.2.6 I started to receive following error:

An exception of type 'System.Reflection.TargetException' occurred in mscorlib.ni.dll but was not handled in user code

Additional information: Non-static method requires a target.

Some of the errors I could fix by changing following code:

db.DbInstance.Save(dbVATBookings.AsEnumerable());

to:

db.DbInstance.Save(dbVATBookings);

with dbVATBookings being a list. I'm still receiving it on saving a list of users though. I've tried saving both a IEnumerable and aList`, but the issue shows on both.

Here's the model we're failing to save:

public partial class User : ModelBase
{
    public string INSS { get; set; }
    public string PIN { get; set; }
    public string Firstname { get; set; }
    public string Lastname { get; set; }
    public string ImagePath { get; set; }
    public string MobilePhone { get; set; }
    public string LandlinePhone { get; set; }
    public string Email { get; set; }
    public string Facebook { get; set; }
    public string Nationality { get; set; }
    public string BirthLocation { get; set; }
    public int Gender { get; set; }
    public string Street { get; set; }
    public string StreetNumber { get; set; }
    public string BoxNumber { get; set; }
    public string Zip { get; set; }
    public string Municipality { get; set; }
    public string Country { get; set; }
    // [XmlIgnore] // tried this, no fix
    public Guid[] TokenGuid { get; set; }
    public int ClockingStatus { get; set; }
    public DateTimeOffset ClockingEventDate { get; set; }

    public Guid? UserProfileId { get; set; }

    private UserProfile _userProfile;
    [XmlIgnore] // to avoid DB Serialization
    public UserProfile UserProfile
    {
        get
        {
            //return this.UserProfileId.HasValue ? _userProfile ?? (_userProfile = LexDbService.GetInstance().Result.UserProfiles.LoadByKey(this.UserProfileId.Value)) : null;
            if (this.UserProfileId.HasValue)
            {
                _userProfile = LexDbService.GetInstance().UserProfiles.LoadByKey(this.UserProfileId.Value);
                if (!ReferenceEquals(_userProfile, null) && !_userProfile.IsDeleted)
                    return _userProfile;
            }

            return null;
        }
        set
        {
            _userProfile = value;
            this.SyncUserProfile();
        }
    }

    private void SyncUserProfile()
    {
        if (!ReferenceEquals(this.UserProfile, null))
            this.UserProfileId = this.UserProfile.Id;
    }

    public override object SortingField
    {
        get { return string.Concat(this.Firstname, this.Lastname); }
    }
}

public abstract class ModelBase : IModelBase
{
    public Guid Id { get; set; }
    public DateTime Timestamp { get; set; }
    [XmlIgnore]
    public ObjectState ObjectState { get; set; }
    public bool IsSynched { get; set; }
    public bool IsDeleted { get; set; }

    /// <summary>
    /// Indicate what field we want to sort on
    /// </summary>
    [XmlIgnore]
    public virtual object SortingField { get; set; }
}

.Net Native Error

I´m using lex.db to load users from the db in a Windows 10 universal app. Whilst I execute it using the normal compiler everything works perfectly. But when selecting the

Compile with .NET Native tool chain

checkbox in the project-> build properties

I get an exception when calling this method:

var person = _placeDb.LoadByKey<Person>(id);

Unhandled exception at 0x02BC8831 (SharedLibrary.dll) in App10.exe: 0x80004005: Unspecified error.

I cloned the repository added a test app, and the method is failing when compiling in native is:

Add(Allocation.New(node)); in the Gather method of the DataMap.cs class

Do you have any idea why could it be?

Regards.

Read database data

How do I read the .data and .index files that are in my device? I mean, reading them in my computer, for making analysis of the data (like using a SQLite reader or something).
Thanks!

Exceptions in WPF and WinRT versions, see attached test program

Created a small test program to test saving/loading/clearing database when using for storing downloaded images.

I found some issues in the WinRT and WPF version. You can run the linked test project and use the start button to start automatic testing. The errors appear in the output console. Hope you have some time to look into this. Have listed the errors as well in the main code behind source files.

link: http://dl.dropbox.com/u/65341396/DownloadImageError.W8.zip

WinRT:

// Error 1: This one happens sometimes when closing the program, launching again and starting the test

ERROR==>System.ArgumentException: Invalid index stream

// Error 2: This one happens randomly. Seems to be a pattern that this can happen when a LoadImageFromDb() is requested after a ClearDb(), but does not happen always

ERROR==>System.IO.EndOfStreamException: Unable to read beyond the end of the stream.

// Error 3: This error happens sometimes, saw it only a very few times

A first chance exception of type 'System.NullReferenceException' occurred in Lex.Db.DLL

WPF:

class DbSchemaStorage : IDbSchemaStorage

public void Purge()
{
if (Directory.Exists(_path))
Directory.Delete(_path, true);

  Directory.CreateDirectory(_path);
}

ERROR 1: In Purge(): The process cannot access the file 'ImageCacheRecord.index' because it is being used by another process.

ERROR 2: In Purge(): The directory is not empty.

class DbTableStorage : IDbTableStorage

public IDbTableWriter BeginWrite()
{
_lock.EnterWriteLock();
try
{
return new Writer(this, _lock.ExitWriteLock);
}
catch
{
_lock.ExitWriteLock();
throw;
}
}

ERROR 3: In BeginWrite: Cannot aquire read lock

Xamarin Forms iOS - Path is Null

I'm developing a cross platform app in Xamarin Forms. I have added Lex.DB to my Portable Class Library. When I try to call Initialize() on DbInstance, I receive a NullReferenceException error. This only happens in iOS (both device and simulator), but it works fine on Android. I notice that the Path property is null on DbInstance (see screenshot).

What am I doing wrong here?
screen shot 2016-02-22 at 1 19 25 pm

screen shot 2016-02-22 at 1 23 30 pm

LexDb should respect IgnoreDataMember annotation.

LexDb is currently not respecting standard DataContract annotation for naming columns and excluding selected properties from table using IgnoreDataMember. Using XmlIgnore is quite non-standard.

Windows 10 Universal App Platform error

HI, I'm using 1.2.4 on UAP, but when I get/save anything with lex.db it will throw 'System.InvalidOperationException' in Lex.Db.dll. When I check the LocalState folder of the app, the lex.db folder has nothing inside.
capture
capture1

Exception related to StorageFile.GetBasicPropertiesAsync on Windows 8.1

I am seeing lot of these exceptions on my Win8.1 machine running Win8 app with Lex.db:

at Windows.Storage.StorageFile.GetBasicPropertiesAsync()
at Lex.Db.WindowsStorage.DbTableStorage.Reader.UpdateTs()
at Lex.Db.WindowsStorage.DbTableStorage.Reader..ctor(DbTableStorage table, Action finalizer)
at Lex.Db.WindowsStorage.DbTableStorage.BeginRead()
at Lex.Db.DbInstance.BulkReadScope.GetReader(DbTable table)
at Lex.Db.DbTable1.ReadScope()
at Lex.Db.DbTable1.LoadByKey[K](K key)
at Lex.Db.DbTableAsync.<>c__DisplayClassd`2.b__c()
at System.Threading.Tasks.Task1.InnerInvoke()
at System.Threading.Tasks.Task.Execute()
A first chance exception of type 'System.InvalidOperationException' occurred in mscorlib.dll
WinRT information: Cannot call the requested method (GetBasicPropertiesAsync). A previous call to this method is pending and must return before the method can be called again.

Any idea what's wrong? Is it possible this is some new issue on Windows 8.1 preview? Maybe misuse of GetBasicPropertiesAsync?

UWP release build error

First of all thank you for your storage solution I have used it many times and works great, however in my current project after building in release I get the following error:

Exception thrown: 'Internal.Runtime.TypeLoader.TypeBuilder.MissingTemplateException' in System.Private.TypeLoader.dll
Exception thrown: 'System.Reflection.MissingMetadataException' in System.Private.CoreLib.dll
Additional information: Reflection_InsufficientMetadata_EdbNeeded: Lex.Db.Serialization.ListSerializers<System.Guid>

Have you came across something similar?

Xamarin.iOS

Hello,
The Xamarin.iOS package dosen't work. For work with lex.db in iOS we need to compile the source and it's works fine, but the nuget package dosen't work.
Thank you!

Deploying an existing Lex.Db database in to WinRT app

Hi,

I´m creating a Lex.Db database from a WPF app, I´m adding this files to the WinRT project.

var root = string.Format("{0}\\{1}", Package.Current.InstalledLocation.Path, "Data\\Lex.Db");

            _db = new DbInstance("PersonDb", root);
            _db.Map<Person>().Automap(i => i.MID);
            _db.Initialize();

But an IO not found exceptio is thrown. I don´t want to create or copy manually my database to the IsolatedStorageFile, because I already have it there, in the Appx folder. Is there any way to tell lex.db to work againts that path? regards.

Searching

Is there any guidance for how to perform partial match (i.e. LIKE '%%') searching on indexes / tables within lex.db? I am currently having to do a full table load and filter the enumerable.

If nothing currently exists I will have a look to see if I can implement the functionality within lex.db myself.

Thanks

LoadByKey Fails Because Key Is Object But IKeyIndex<T, K> Needs K of Key Type

Version 1.1.3.0:

public T LoadByKey < T > (object key) where T : class
{
return Table < T > ().LoadByKey(key);
}
...
var result = KeyIndex as IKeyIndex < T, K >;

The cast attempts to use object as K when in fact the type of the index is expected. Example:

public class Record
{
public long Id {get;set;}
}

Database.LoadByKey(7), causes an exception to be thrown:

{System.ArgumentException: Primary Index Object mismatch (Int64 expected)
at Lex.Db.DbTable1.GetPrimaryIndex [ K ] () at Lex.Db.DbTable1.LoadByKey [ K ](K key)
at Lex.Db.DbInstance.LoadByKey [ T ](Object key)
...

Specified method is not supported.

I am trying to add Lex.DB to a Windows Phone app. I am getting Specified method is not supported. when calling SaveAsync. Is it that the SaveAsync method is not supported? Or is there some problem in my data?

LoadByCompositeKey?

How is it possible to load an entity by a composite primary key?

I would like to load an entity as follows:

Person person = databaseInstance.LoadByCompositeKey(pk1, pk2);

Is db.Dispose() necessary?

I'm making a Windows Phone 8.1 app, I have several pages and UserControls that creates their own DbInstance. These pages/usercontrols are destroyed after navigating from them. So, should I dispose the DbInstances before destroying the page?

iOS support via Xamarin.iOS

Is it possible to have iOS support? If it is, please give me a rough direction and I'll try to do the port

Same model objects in different tables

I want to have like multiple tables with the same type of object and not getting them in the same place. Is it possible? Currently I'm doing it by creating different DbInstances. Is this right?

ArgumentException when using 3 member index on iOS.

While running code equivalent to that below on iOS, an ArgumentException is thrown with the message:

method return type is incompatible

The code that causes the error is equivalent to the below pseudocode, with the exception being thrown as a response to the invocation of WithIndex. Using the WithIndex method with only two arguments work as expected.

var database = new DbInstance(path, "");
database
    .Map<SomeClass>()
    .Automap(i => i.Key)
    .WithIndex("some-index", i => i.Name, i => i.Color, i => i.Size);
database.Initialize();

While searching through the Lex.Db source code, I found the following line of particular interest. It looks like a classical typo bug, with member2 being used to produce a value for getter3.

Xamarin iOS Error

I'm using LexDb.iOS 1.2 in a xamarin ios application.

If i Execute in the emulator evrithings goes perfectly, but if I debug in a ios phone then:

When I try to do the

db.Save(item);

throws this exception:

Attemptin to JIT compile method '(wrapper delegate-invoke):invoke_callvirt_Nullable'1_User(Entities)' while running with --aot only. See http://xamarinsupport for more information.)

I have to do somthing different when I execute in the phone?

Thanks.

After Delete IndexQuery on table returns no records (WinRT)

I could reproduce the following problem:

public class TemplateModel
{
public int Id { get; set; }
///

        /// Denormalized. String of comma seperated Integer Id of some items
       /// </summary>


       public string ForeignIds { get; set; }
       public string Name { get; set; }
       public int Type { get; set; }
    }
       //mapping done before init
        db.Map<TemplateModel>().Automap(i => i.Id, false).WithIndex<int>("Type", i => i.Type);

        //testing this in a method
        this._db.Table<TemplateModel>().Save(new TemplateModel(66, "test", new List<ForeignIds>(), 3));
        this._db.Table<TemplateModel>().Save(new TemplateModel(67, "test2", new List<ForeignIds>(), 3));
        //The Type is 3 for both records 
        //The first indexQuery returns 2 records, OK!
        var indexQuery = _db.Table<TemplateModel>().IndexQueryByKey<int>("Type", 3).ToList();

        this._db.Table<TemplateModel>().DeleteByKey<int>(67);

        //allItems returns 1 record, OK!
        var allItems = _db.Table<TemplateModel>().LoadAll().ToList();

        //indexQuery2 returns 0 records, wrong!
        var indexQuery2 = _db.Table<TemplateModel>().IndexQueryByKey<int>("Type", 3).ToList();

        if (indexQuery2.Count() != 1)
            throw new Exception("Should be 1");

Feature request: Sorting index-query results by index key.

I would like to request the possibility to sort results of index-queries based on index key values.

Basically, I have an index that contains <string, long?> (name, parent ID), that I want to use for fetching entry children. My index is sorted by name using StringComparer.OrdinalIgnoreCase, but I want to present them using the order of StringComparer.CurrentCultureIgnoreCase. I don't know the user's current culture when I generate the index, and the user can change culture at any time.

I would like to be able to do something like the following:

var entries = database
    .Table<MyEntry>()
    .IndexQuery<string, long?>("NameParentId")
    .Where((iName, iParentId) => Object.Equals(parentId, iParentId))
    .Sort(StringComparer.CurrentCultureIgnoreCase, null)
    .Skip(2000)
    .Take(400)
    .ToList();

Unable to target portable .NET profile 111

Hi,

Recently I tried to update to version 1.2.6 of Lex.Db, but was confronted with the following error:

Could not install package 'Lex.Db 1.2.6'. You are trying to install this package into a project that targets '.NETPortable,Version=v4.5,Profile=Profile111', but the package does not contain any assembly references or content files that are compatible with that framework. For more information, contact the package author.

This is selected PCL profile:
image

Could you please assist?
Kind regards,
Richard

[iOS] - Cannot store/retrieve float data type

I think I have discovered a limitation on iOS. One of my model classes has a float datatype. I think it save fine but when I try to read it back out I get the following error...

Attempting to JIT compile method '(wrapper delegate-invoke) :invoke_callvirt_void_CustomDataValueNumeric_single (MyProject.Model.CustomDataValueNumeric,single)' while running with --aot-only. See http://docs.xamarin.com/ios/about/limitations for more information.

screen shot 2016-06-09 at 11 54 02 am

Save doesn't work if passed object

Sorry - I struggled to come up with a helpful subject line for this one. Here is what I'm trying to do ... I've got a generic "InsertRecord" method where I pass the object I want to save, e.g.:

public void InsertRecord(object item)
{
LexDB.Save(item);
}

(It is written like this as I've abstracted all of the database routines into a database class so that I can switch between SQLite & Lex.DB whilst testing and as Lex.DB progresses.)

So InsertRecord might be called like this:

rhFile = new RHFile();
thisDB.InsertRecord(rhFile);

where RHFile is a class defined as a table in the database. However, when the code gets to InsertRecord, I get this error:

Type Object is not registered with this DbInstance

even though if I set a breakpoint here and go item.GetType(), this is the output:

item.GetType()
{Name = "RHFile" FullName = "Relative_History.RHFile"}
[System.RuntimeType]: {Name = "RHFile" FullName = "Relative_History.RHFile"}
base {System.Reflection.MemberInfo}: {Name = "RHFile" FullName = "Relative_History.RHFile"}
Assembly: {Relative History, Version=1.0.0.0, Culture=neutral, PublicKeyToken=null}
AssemblyQualifiedName: "Relative_History.RHFile, Relative History, Version=1.0.0.0, Culture=neutral, PublicKeyToken=null"
Attributes: Public | BeforeFieldInit
BaseType: {Name = "Object" FullName = "System.Object"}
ContainsGenericParameters: false
DeclaringMethod: 'item.GetType().DeclaringMethod' threw an exception of type 'System.InvalidOperationException'
DeclaringType: null
FullName: "Relative_History.RHFile"
GenericParameterAttributes: 'item.GetType().GenericParameterAttributes' threw an exception of type 'System.InvalidOperationException'
GenericParameterPosition: 'item.GetType().GenericParameterPosition' threw an exception of type 'System.InvalidOperationException'
GenericTypeArguments: {System.Type[0]}
GUID: {69a4228a-4932-3bbe-a99d-ca33fad001e9}
HasElementType: false
IsAbstract: false
IsAnsiClass: true
IsArray: false
IsAutoClass: false
IsAutoLayout: true
IsByRef: false
IsClass: true
IsCOMObject: false
IsConstructedGenericType: false
IsContextful: false
IsEnum: false
IsExplicitLayout: false
IsGenericParameter: false
IsGenericType: false
IsGenericTypeDefinition: false
IsImport: false
IsInterface: false
IsLayoutSequential: false
IsMarshalByRef: false
IsNested: false
IsNestedAssembly: false
IsNestedFamANDAssem: false
IsNestedFamily: false
IsNestedFamORAssem: false
IsNestedPrivate: false
IsNestedPublic: false
IsNotPublic: false
IsPointer: false
IsPrimitive: false
IsPublic: true
IsSealed: false
IsSecurityCritical: true
IsSecuritySafeCritical: false
IsSecurityTransparent: false
IsSerializable: false
IsSpecialName: false
IsUnicodeClass: false
IsValueType: false
IsVisible: true
MemberType: TypeInfo
Module: {Relative History.exe}
Namespace: "Relative_History"
ReflectedType: null
StructLayoutAttribute: {System.Runtime.InteropServices.StructLayoutAttribute}
TypeHandle: {System.RuntimeTypeHandle}
TypeInitializer: null
UnderlyingSystemType: {Name = "RHFile" FullName = "Relative_History.RHFile"}

Is there something you can do to figure out that what I've passed isn't an "Object" but is, instead, an RHFile instance?

Windows Universal Apps

Hello, Do you plan to adapt your LexDb for Windows Universal Apps?

Now I can install it into the project, but if you try to go through validation you will get an error, that LexDb has incompatible APIs.

◦This API is not supported for this application type - Api=CloseHandle. Module=api-ms-win-core-file-l1-2-0.dll. File=Lex.Db.dll.
◦This API is not supported for this application type - Api=GetFileInformationByHandleEx. Module=api-ms-win-core-file-l1-2-0.dll. File=Lex.Db.dll.
◦This API is not supported for this application type - Api=MoveFileEx. Module=api-ms-win-core-file-l1-2-0.dll. File=Lex.Db.dll.

Support for SortedSet<T>

Hello, do you plan to add native support for saving SortedSet in Lex.Db? Or maybe you can suggest how can I save it now?

Thanks.

System.NullReferenceException on Save

I'm trying to use lex.db in windows phone 8.1 universal app with latest nuget available version 1.2.2
Simple code on Save throws exeption

       db = new DbInstance("rebloged");
       db.Map<Rebloged>()
          .Automap(i => i.Id, true)
          .WithIndex("re", i => i.ReId);

        db.Initialize();

        db.Save(new Rebloged { ReId = "Lex" },
                new Rebloged { ReId = "John" },
                new Rebloged { ReId = "Scott" },
                new Rebloged { ReId = "John" });

public class Rebloged
{
    public int Id { get; set; }
    public string ReId { get; set; } 
}
System.NullReferenceException: Object reference not set to an instance of an object.
   at Lex.Db.Indexing.DataIndex`2.Update(IKeyNode keyNode, T instance)
   at Lex.Db.DbTable`1.WriteObjectData(IDbTableWriter writer, T instance, Byte[] data, Int32 length)
   at Lex.Db.DbTable`1.Save(IEnumerable`1 items)
   at Lex.Db.DbInstance.Save[T](T[] items)

Sample project - https://yadi.sk/d/g8Wf_nL1fxvP5

Database upgrade problem from 8.1 to 10

Hi, when testing upgrade compatible from Windows 8.1 app to Windows 10 by coping the db folder, I got this error (items class are the same)

Unknown type code 101
at Lex.Db.Serialization.DbTypes.GetType(Int16 type)
at Lex.Db.Serialization.DbType..ctor(SByte id)
at Lex.Db.Serialization.DbType.Read(DataReader reader)
at Lex.Db.MemberMap..ctor(DataReader reader)
at Lex.Db.MemberMap1..ctor(DataReader reader) at Lex.Db.Mapping.Metadata1..ctor(DataReader reader, UInt32 hash)
at Lex.Db.Mapping.Metadata1.Read(DataReader reader) at Lex.Db.DbTable1.ReadIndexes(Stream stream)
at Lex.Db.DbTable1.Read(IDbTableReader reader) at Lex.Db.DbInstance.BulkReadScope.GetReader(DbTable table) at Lex.Db.DbTable1.ReadScope()
at Lex.Db.DbTable1.<GetEnumerator>d__88.MoveNext() at System.Linq.Enumerable.LastOrDefault[TSource](IEnumerable1 source)
at MoneyLover.Db.Task.GetUserTask.d__0.MoveNext()

This is the class:

public class users
{
public int id { get; set; }
public string user_sync_id { get; set; }
public string access_token { get; set; }
public string email { get; set; }
public int gold { get; set; }
public long last_sync { get; set; }
public int lock_type { get; set; }
public string hash_pass { get; set; }
public int account_default { get; set; }
public long last_sync_campaign { get; set; }
public long last_sync_budget { get; set; }
}

The given key was not present in the dictionary

The following line of code is giving me the error in the title:

LexDB.Table<RHObject>().LoadAll().OrderByDescending(i => i.ID).Take(12).ToList();

The stack trace is:

       at System.Collections.Generic.Dictionary`2.get_Item(TKey key)
       at Lex.Db.Indexing.DataIndex`2.ReadNode(DataReader reader, Dictionary`2 keyMap, DataNode`1 parent)
       at Lex.Db.Indexing.DataIndex`2.Read(DataReader reader, DbFormat format)
       at Lex.Db.DbTable`1.ReadIndexes(Stream stream)
       at Lex.Db.DbTable`1.LoadIndex(IDbTableReader reader)
       at Lex.Db.DbInstance.BulkReadScope.GetReader(DbTable table)
       at Lex.Db.DbTable`1.ReadScope()
       at Lex.Db.DbTable`1.LoadAll()

I'm at a loss as to what might be causing this, hence the issue report :-).

Philip

Unable to read beyond the end of the stream

My app is throwing a System.IO.EndOfStreamException when using Lex.Db:

StackTrace:
            at System.IO.BinaryReader.FillBuffer(Int32 numBytes)
            at System.IO.BinaryReader.ReadInt32()
            at Lex.Db.Serialization.Serializers.ReadInt(DataReader reader)
            at lambda_method(Closure , DataReader , RHObject )
            at Lex.Db.Mapping.Metadata`1.Deserialize(DataReader reader, T item)
            at Lex.Db.DbTable`1.LoadByKeyInfo(Scope`1 scope, Location`1 info)
            at Lex.Db.DbTable`1.LoadByKeyNode(Scope`1 scope, IKeyNode node)
            at Lex.Db.Indexing.DataIndex`2.<>c__DisplayClassc.<ExecuteToList>b__a(K k, IKeyNode pk)
            at Lex.Db.Indexing.DataIndex`2.<>c__DisplayClass6`1.<ExecuteQuery>b__5(DataNode`1 i, IKeyNode k)
            at System.Linq.Enumerable.<SelectManyIterator>d__31`3.MoveNext()
            at System.Collections.Generic.List`1..ctor(IEnumerable`1 collection)
            at System.Linq.Enumerable.ToList[TSource](IEnumerable`1 source)
            at Lex.Db.Indexing.DataIndex`2.ExecuteToList(IndexQueryArgs`1 args)
            at Lex.Db.IndexQueryBase`3.ToList()
            at Lex.Db.DbTableAsync.<>c__DisplayClass13`2.<ToListAsync>b__12()
            at System.Threading.Tasks.Task`1.InnerInvoke()
            at System.Threading.Tasks.Task.Execute()

The code that is executing at the time is:

return LexDB.Table<RHObject>().IndexQueryByKey("Key", query).ToListAsync();

The table is defined thus:

db.Map<RHObject>()
                .Key(i => i.ID, true)
                .Map(i => i.MultimediaFormat)
                .Map(i => i.DescriptiveTitle)
                .Map(i => i.FileReference)
                .Map(i => i.StoredFile)
                .Map(i => i.Key)
                .Map(i => i.Rotation)
                .Map(i => i.RHEvent)
                .Map(i => i.RHFamilyRecord)
                .Map(i => i.RHIndividualRecord)
                .Map(i => i.RHSourceCitation)
                .Map(i => i.RHSourceRecord)
                .Map(i => i.RHSubmitterRecord)
                .WithIndex("StoredFile", i => i.StoredFile)
                .WithIndex("Key", i => i.Key)
                .WithIndex("RHEvent", i => i.RHEvent)
                .WithIndex("RHFamilyRecord", i => i.RHFamilyRecord)
                .WithIndex("RHIndividualRecord", i => i.RHIndividualRecord)
                .WithIndex("RHSourceCitation", i => i.RHSourceCitation)
                .WithIndex("RHSourceRecord", i => i.RHSourceRecord)
                .WithIndex("RHSubmitterRecord", i => i.RHSubmitterRecord);

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.