Hi,

I've encountered the following Problem while using your DataObjects.NET 4.3 for .NET 3.5:

I've got the following Situation: There's a so called "StorageToDiscover", which looks like this:

[Serializable]
[HierarchyRoot]
public class CelerraToDiscover : Entity
{
    [Field, Key]
    public int ObjectID { get; private set; }

    [Field]
    public char Status { get; set; }

    [Field]
    public int AgentID { get; set; }

    [Field(Length = 256)]
    public string SystemName { get; set; }

    [Field(Length = 64)]
    public string PluginName { get; set; }

    [Field(Length = 64)]
    public string Username { get; set; }

    [Field(Length = 512)]
    public string Password { get; set; }

    [Field(Length = 15)]
    public string StorageIP { get; set; }

    public int CustomerID { get; set; }
    //public List<StorageCelerraDisk> Disks { get; set; }
    //public List<StorageCelerraPool> Pools { get; set; }
    //public List<StorageCelerraFilesystems> Filesystems { get; set; }

    public CelerraToDiscover(int objectID)
        : base(objectID)
    { }

Which is created by a Web-Frontend into the Database, Querying this Object works without any problems, eg. like this:

var bla2 = Query.All<CelerraToDiscover>();

The Backend loads this Entity, works with it and saves it as DiscoveredStorage into the Database, with the SAME ObjectID as the StorageToDiscover (which is intended).

The DiscoveredStorage Entity looks like this:

[Serializable]
[HierarchyRoot]
public class StorageCelerra : Entity
{
    [Field, Key]
    public int ObjectID { get; private set; }

    [Field]
    public char Status { get; set; }

    [Field(Length = 128)]
    public string StorageStatus { get; set; }

    [Field(Length = 256)]
    public string Type { get; set; }

    [Field(Length = 256)]
    public string SerialNumber { get; set; }

    [Field(Length = 256)]
    public string Version { get; set; }

    [Field(Length = 256)]
    public string Host { get; set; }

    [Field(Length = 256)]
    public string Name { get; set; }
    public StorageCelerra(int objectID)
        : base(objectID)
    {
    }
}

After this Instance is saved, I want to upadte it's properties. Therefore I Query it from the Database like this:

var bla = Query.All<StorageCelerra>();

Which leads to this Error:

Exception:

{"Invalid TupleDescriptor. Expected descriptor is TupleDescriptor(Int32, Int32, Char, Int32, String, String, String, String, String).\r\nParameter name: difference"}System.SystemException {System.ArgumentException}
StackTrace:
at Xtensive.Core.Tuples.TupleExtensions.MergeWith(Tuple origin, Tuple difference, Int32 startIndex, Int32 length, MergeBehavior behavior)
at Xtensive.Core.Tuples.TupleExtensions.MergeWith(Tuple origin, Tuple difference, MergeBehavior behavior)
at Xtensive.Storage.EntityState.Update(Tuple update)
at Xtensive.Storage.Session.UpdateEntityState(Key key, Tuple tuple, Boolean isStale)
at Xtensive.Storage.Session.UpdateEntityState(Key key, Tuple tuple)
at Xtensive.Storage.Providers.SessionHandler.UpdateEntityStateInSessionCache(Key key, Tuple tuple, Boolean isStale)
at Xtensive.Storage.Providers.SessionHandler.RegisterEntityState(Key key, Tuple tuple)
at Xtensive.Storage.Linq.Materialization.ItemMaterializationContext.Materialize(Int32 entityIndex, Int32 typeIdIndex, TypeInfo type, Pair`1[] entityColumns, Tuple tuple)
at lambda_method(Closure , Object[] , Tuple , ItemMaterializationContext )
at Xtensive.Core.DelegateBindExtensions.<>c__DisplayClassa`4.<Bind>b__9(T2 arg2, T3 arg3)
at Xtensive.Storage.Linq.Materialization.MaterializationHelper.<>c__DisplayClass4`1.<Materialize>b__3(Tuple tuple)
at System.Linq.Enumerable.WhereSelectEnumerableIterator`2.MoveNext()
at Xtensive.Core.EnumerableExtensions.<Batch>d__27`1.MoveNext()
at Xtensive.Core.EnumerableExtensions.<ApplyBeforeAndAfter>d__2f`1.MoveNext()
at Xtensive.Storage.TransactionalExtensions.<ToTransactional>d__0`1.MoveNext()
at System.Linq.Enumerable.<SelectManyIterator>d__14`2.MoveNext()
at System.Linq.SystemCore_EnumerableDebugView`1.get_Items()"

But, I can see the Item in the Database: alt text

Why can't I query it?

I hope the description of my problem was understandable, thanks in advance & greetings

Simon

asked Nov 02 '10 at 11:38

SimonRieger's gravatar image

SimonRieger
7113

edited Nov 06 '10 at 05:35

Alex%20Yakunin's gravatar image

Alex Yakunin
29714412


2 Answers:

According to your post, both mentioned hierarchies share the same key generator (key space), while 'StorageCelerra ' type doesn't need one because its constructor always receives ObjectId parameter. So, try adding the following line to the 'StorageCelerra' class definition:

[KeyGenerator(KeyGeneratorKind.None)]

Hope that helps.

answered Nov 02 '10 at 12:26

Dmitri%20Maximov's gravatar image

Dmitri Maximov
22111211

edited Nov 02 '10 at 12:27

that did it, thank you very much

answered Nov 03 '10 at 04:51

SimonRieger's gravatar image

SimonRieger
7113

You are welcome

(Nov 03 '10 at 05:23) Dmitri Maximov Dmitri%20Maximov's gravatar image
Your answer
Please start posting your answer anonymously - your answer will be saved within the current session and published after you log in or create a new account. Please try to give a substantial answer, for discussions, please use comments and please do remember to vote (after you log in)!
toggle preview

powered by OSQA