Breaking Changes?

Posts   
 
    
simmotech
User
Posts: 1024
Joined: 01-Feb-2006
# Posted on: 19-Apr-2012 11:39:34   

I mentioned in another thread I was reusing some code from a few years back (v2.6) and, once I referenced the new Runtime DLLs for v3.5, found it wouldn't compile. This isn't a problem - I just need to get the thing compiling again.

I've look through the Breaking Changes and found some issues that appear unlisted. I thought I would list them here in case you want to add them to the list for completeness. 1) Signatures for Predicate.ToQueryText have changed: ref int uniqueMarker parameter has been removed 2) IExpression.ToQueryText signatures have also changed as per (1) 3) IExpression.Parameters has changed type: was IList<IDataParameter> and is now List<DBParameter> 4) IEntityFieldCore adds some new items. Only relevant if you wrap an IEntityFieldCore which is probably rare. bool IsOfEnumDataType { get; } Type RealDataType { get; } void AddLinkedSubTypeField(IEntityFieldCore linkedSubTypeField) void AcceptChange() void RejectChange() void SetFieldIndex(int newIndex) ForcedChangedWrite(bool isChangedValue) SetDbValue(object value) void WriteXml(XmlWriter writer, XmlFormatAspect aspects) void ForcedIsNullWrite(bool isNull) List<IEntityFieldCore> LinkedSubTypeFields 5) IDbSpecificCreator.CreateFieldName: uniqueMarker parameter removed 6) IDbFunctionCall: DatabaseParameters and Parameters - was IList<IDataParameter> and is now List<DBParameter>

I do have one question about the disappeared uniqueMarker int: The only place my code actually used this value was to create a unqiue DBParameter.ParameterName (by incrementing uniqueMarker then calling ToString() on it). How is your code now generating parameter names? I want to ensure that there will be no clash.

simmotech
User
Posts: 1024
Joined: 01-Feb-2006
# Posted on: 19-Apr-2012 11:51:05   

Part 2: My code had these down as public but

7) EntityBase2.PrimaryKeyFields is now private. 8 ) EntityBase2.ObjectID is now protected. 9) EntityBase2.GetRelatedData() is now protected internal. 10) EntityBase2.GetMemberEntityCollections is now protected.

For (7) I think I can use entity.Fields.PrimaryKeyFields

The others are a bit more problematical since they are in a library Framework.LLBLGen project which won't have access to any generated code - only the LLBLGen runtime libraries. Is reflection my only hope and have these become non-public because they now work in a different way?

Cheers Simon

simmotech
User
Posts: 1024
Joined: 01-Feb-2006
# Posted on: 19-Apr-2012 12:00:59   

9 and 10 were solved (compile-wise at least) by casting to IEntityCore and IEntityCollection2.

So that just leaves ObjectID - why did that become non-public? The use-case for this BTW is

        public static T CloneEntity<T>(T entity, List<Type> excludedTypes, List<EntityBase2> excludeEntityInstances, bool generateNewObjectIDs = false) where T : EntityBase2
        {
            var formatter = new BinaryFormatter(null, new StreamingContext(StreamingContextStates.Clone));
            var stream = new MemoryStream();

            formatter.Serialize(stream, entity);
            stream.Seek(0, SeekOrigin.Begin);

            var clone = (T)formatter.Deserialize(stream);

            var a = new ReferencedEntityMap(clone);
            
            foreach(var e in a.GetSeenEntities())
            {
                if( !excludedTypes.Contains(e.GetType()) &&
                    !excludeEntityInstances.Contains(e))
                {
                    e.IsNew = true;
                    e.IsDirty = true;
                    if (generateNewObjectIDs) e.ObjectID = Guid.NewGuid();
                    e.Fields.IsDirty = true;
                    for (var i = 0; i < e.Fields.Count; i++)
                    {
                        if (e.Fields[i].IsPrimaryKey)
                            e.Fields[i].ForcedCurrentValueWrite(null);

                        e.Fields[i].IsChanged = true;
                    }
                }
            }
            
            return clone;
        }

daelmo avatar
daelmo
Support Team
Posts: 8245
Joined: 28-Nov-2005
# Posted on: 19-Apr-2012 23:40:54   

A lot was refactored, but still accesible, please check IEntityCore interface (which is implemented by EntityBase2), ObjectID is there, so you can do:

((IEntityCore) entity).ObjectID;

This is the case for other of your questions. I will respond point by point later today so you can get a clear picture of what has been changed...

David Elizondo | LLBLGen Support Team
daelmo avatar
daelmo
Support Team
Posts: 8245
Joined: 28-Nov-2005
# Posted on: 20-Apr-2012 06:54:53   

simmotech wrote:

1) Signatures for Predicate.ToQueryText have changed: ref int uniqueMarker parameter has been removed

2) IExpression.ToQueryText signatures have also changed as per (1) Right.

3) IExpression.Parameters has changed type: was IList<IDataParameter> and is now List<DBParameter>

Yes, you are right.

simmotech wrote:

4) IEntityFieldCore adds some new items. Only relevant if you wrap an IEntityFieldCore which is probably rare. bool IsOfEnumDataType { get; } Type RealDataType { get; } void AddLinkedSubTypeField(IEntityFieldCore linkedSubTypeField) void AcceptChange() void RejectChange() void SetFieldIndex(int newIndex) ForcedChangedWrite(bool isChangedValue) SetDbValue(object value) void WriteXml(XmlWriter writer, XmlFormatAspect aspects) void ForcedIsNullWrite(bool isNull) List<IEntityFieldCore> LinkedSubTypeFields

A lot of code that uses IEntity/2 and IEntityField/2 was refactored to use IEntityCore and IEntityFieldCore, so now a lot of framework methods receives IEntityCore/IEntityFieldCore. Now ORMSupportClasses is more compact and is more easily to work with it. If you use Adapter you still use IEntity/IEntityField, if you use SelfServicing you can still use IEntity2/IEntityField2. However both implements IEntityCore/IEntityFieldCore. So for the Framework it's better. This is mentioned in the docs, but not in a great detail, but the rule applies in general.

simmotech wrote:

5) IDbSpecificCreator.CreateFieldName: uniqueMarker parameter removed

6) IDbFunctionCall: DatabaseParameters and Parameters - was IList<IDataParameter> and is now List<DBParameter>

Right.

For your 2nd part: All of those are in IEntityCore wink

David Elizondo | LLBLGen Support Team
simmotech
User
Posts: 1024
Joined: 01-Feb-2006
# Posted on: 20-Apr-2012 08:20:21   

Thanks David.

Otis avatar
Otis
LLBLGen Pro Team
Posts: 39910
Joined: 17-Aug-2003
# Posted on: 20-Apr-2012 11:07:45   

Re:

I do have one question about the disappeared uniqueMarker int: The only place my code actually used this value was to create a unqiue DBParameter.ParameterName (by incrementing uniqueMarker then calling ToString() on it). How is your code now generating parameter names? I want to ensure that there will be no clash.

As v3 has refactored DQE's, we moved a lot of code to the base classes as we now use DbProviderFactory to create the actual objects.

The uniquemarker is still there, but it's hidden away. There's 1 instance per DQE instance, and if you want to create a parameter, simply ask the DQE's DbSpecificCreator (available on the Creator property) to create a parameter for you. This will then always be in-line with the rest of the parameters created by the DQE.

Frans Bouma | Lead developer LLBLGen Pro