Skip to content

Commit

Permalink
Merge branch 'hotfix/1.13.3'
Browse files Browse the repository at this point in the history
  • Loading branch information
Kal Ahmed committed Jan 8, 2017
2 parents 1e6484e + 30a330f commit b24f976
Show file tree
Hide file tree
Showing 8 changed files with 67 additions and 16 deletions.
2 changes: 1 addition & 1 deletion common.proj
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@
<PropertyGroup>
<Major>1</Major>
<Minor>13</Minor>
<Build>2</Build>
<Build>3</Build>
<Revision>0</Revision>
</PropertyGroup>

Expand Down
6 changes: 6 additions & 0 deletions doc/src/Whats_New.rst
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,12 @@ This section gives a brief outline of what is new / changed in each official rel
either data migration or code changes in client code, these are marked with **BREAKING**. New features are marked with NEW and fixes for issues are
marked with FIX. A number in brackets like this (#123) refers to the relevant issue number in our GitHub issue tracker.

****************************
BrightstarDB 1.13.3
****************************

- FIX: Another fix to the EntityFramework to ensure that an object's hashcode remains stable after it is deleted. This is needed to support wrapping entity collections as observable collections in MvvmLight (#290)

****************************
BrightstarDB 1.13.2
****************************
Expand Down
2 changes: 1 addition & 1 deletion doc/src/conf.py
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,7 @@
# The short X.Y version.
version = '1.13'
# The full version, including alpha/beta/rc tags.
release = '1.13.2'
release = '1.13.3'

# The language for content autogenerated by Sphinx. Refer to documentation
# for a list of supported languages.
Expand Down
2 changes: 1 addition & 1 deletion installer/PackageFiles/README.txt
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ into the main documentation.

Version
-------
1.13.2
1.13.3

We welcome feedback, comments, feature requests and bug reports sent to
support@brightstardb.com.
Expand Down
10 changes: 4 additions & 6 deletions src/core/BrightstarDB.Tests/DynamicObjectTests.cs
Original file line number Diff line number Diff line change
Expand Up @@ -303,20 +303,18 @@ public void TestSampleCode()
brightstar = dynaStore.GetDataObject(id);

// property values are ALWAYS collections.
var name = brightstar.Name.FirstOrDefault();
Console.WriteLine("Name = " + name);
var name = brightstar.name.FirstOrDefault();
Assert.AreEqual("BrightstarDB", name);

// they can be enumerated without a cast
foreach (var l in brightstar.rdfs__label)
{
Console.WriteLine("Label = " + l);
Assert.IsTrue(l.Equals("BrightstarDB") || l.Equals("NoSQL Database"));
}

// object relationships are navigated in the same way
var p = brightstar.rdfs__type.FirstOrDefault();
Console.WriteLine(p.rdfs__label.FirstOrDefault());

Console.ReadLine();
Assert.AreEqual("Product", p.rdfs__label.FirstOrDefault());
}
}
}
Expand Down
5 changes: 4 additions & 1 deletion src/core/BrightstarDB.Tests/EntityFramework/LinqTests.cs
Original file line number Diff line number Diff line change
Expand Up @@ -1499,9 +1499,12 @@ public void TestLinqWhere()
Assert.AreEqual(1, x.Count());
Assert.AreEqual("Annie", x.First().Name);

var annie = context.Persons.Where(p => p.Name.Equals("Annie")).SingleOrDefault();
var annie = context.Persons.Where(p => p.Name.Equals("Annie")).FirstOrDefault();
Assert.IsNotNull(annie);

//annie = context.Persons.Where(p => p.Name.Equals("Annie")).SingleOrDefault();
//Assert.IsNotNull(annie);

var mainSkillsOfPeopleOver30 = from s in context.Skills where s.Expert.Age > 30 select s;
var results = mainSkillsOfPeopleOver30.ToList();
Assert.AreEqual(1, results.Count);
Expand Down
33 changes: 33 additions & 0 deletions src/core/BrightstarDB.Tests/EntityFramework/SimpleContextTests.cs
Original file line number Diff line number Diff line change
Expand Up @@ -1999,6 +1999,39 @@ public void TestDeleteEntity()
}
}

public void TestDeletedEntityRetainsItsHashcode()
{
var storeName = "DeletedEntityRetainsHashcode_" + DateTime.Now.Ticks;
IPerson p;
int hashCode;
string jenId;

using (
var context = new MyEntityContext("type=embedded;storesdirectory=c:\\brightstar;storename=" + storeName)
)
{
p = context.Persons.Create();
p.Name = "jen";
context.SaveChanges();
jenId = p.Id;
hashCode = p.GetHashCode();
}
using (
var context = new MyEntityContext("type=embedded;storesdirectory=c:\\brightstar;storename=" + storeName)
)
{
p = context.Persons.FirstOrDefault(x => x.Id.Equals(jenId));
Assert.NotNull(p);
Assert.Equals(hashCode, p.GetHashCode());
context.DeleteObject(p);
Assert.Equals(hashCode, p.GetHashCode());
context.SaveChanges();
}
// Even after closing the context the deleted object should retain its hashcode,
// this enables implementation of observable object collections on top of B*
Assert.Equals(hashCode, p.GetHashCode());
}

[Test]
public void TestDeleteEntityInSameContext()
{
Expand Down
23 changes: 17 additions & 6 deletions src/core/BrightstarDB/EntityFramework/BrightstarEntityObject.cs
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,18 @@ public class BrightstarEntityObject : IEntityObject, INotifyPropertyChanged
{
private BrightstarEntityContext _context;
private string _identity;
internal IDataObject DataObject { get; set; }
private IDataObject _dataObject;

internal IDataObject DataObject
{
get { return _dataObject; }
set
{
if (value != null) _identity = value.Identity;
_dataObject = value;
}
}

private readonly Dictionary<string, object> _currentItemValues = new Dictionary<string, object>();
private readonly Dictionary<string, BrightstarEntityObject> _currentPropertyValues = new Dictionary<string, BrightstarEntityObject>();
private readonly Dictionary<string, IBrightstarEntityCollection> _currentPropertyCollections = new Dictionary<string, IBrightstarEntityCollection>();
Expand Down Expand Up @@ -115,7 +126,7 @@ public EntityContext Context
/// property with the object attached to a context.</exception>
protected string Identity
{
get { return DataObject != null ? DataObject.Identity : _identity; }
get { return _identity; }
set
{
if (value == _identity) return;
Expand Down Expand Up @@ -468,7 +479,7 @@ public void SetRelatedObject<T>(string propertyName, T value) where T : class
foreach (var trackedObject in _context.GetTrackedObjects(existingDataObject))
{
var otherCollection = p.GetValue(trackedObject, null) as IBrightstarEntityCollection;
if (otherCollection != null) otherCollection.RemoveFromLoadedObjects(DataObject.Identity);
if (otherCollection != null) otherCollection.RemoveFromLoadedObjects(_identity);
}
}
}
Expand All @@ -486,7 +497,7 @@ public void SetRelatedObject<T>(string propertyName, T value) where T : class
foreach (var p in props)
{
var collection = p.GetValue(trackedObject, null) as IBrightstarEntityCollection;
if (collection != null) collection.RemoveFromLoadedObjects(this.DataObject.Identity);
if (collection != null) collection.RemoveFromLoadedObjects(_identity);
}
}
}
Expand Down Expand Up @@ -883,7 +894,7 @@ public void Unbecome<T>()
/// <filterpriority>2</filterpriority>
public override int GetHashCode()
{
return DataObject.Identity.GetHashCode();
return _identity.GetHashCode();
}

/// <summary>
Expand All @@ -896,7 +907,7 @@ public override int GetHashCode()
public override bool Equals(object obj)
{
var other = obj as BrightstarEntityObject;
return other != null && IsAttached && other.IsAttached && other.DataObject.Identity.Equals(DataObject.Identity);
return other != null && IsAttached && other.IsAttached && other._identity.Equals(_identity);
}
#endregion

Expand Down

0 comments on commit b24f976

Please sign in to comment.