This is a migrated thread and some comments may be shown as answers.

Explicit change tracking required for the array field warning

4 Answers 226 Views
Databases and Data Types
This is a migrated thread and some comments may be shown as answers.
This question is locked. New answers and comments are not allowed.
Gopal
Top achievements
Rank 1
Gopal asked on 03 Mar 2012, 04:17 PM
Hello,
 I have created DomainModel (database approach) using OpenAccess Q3 2011, I have table named Employee having column with datatype as varbinary(max). 
The generated Employee.generated.cs, gives following warning.
Explicit change tracking required for the array field HumanResource.Employee.employeePhoto. [class=HumanResource.Employee] [field=employeePhoto]
below is the excerpt from Employee.generated.cs 

private byte[] employeePhoto; 
[Column("EmployeePhoto", OpenAccessType = OpenAccessType.LongVarBinary, IsNullable = true, SqlType = "varbinary(max)")] 
[Storage("employeePhoto")] 
public virtual byte[] EmployeePhoto 

get 

return this.employeePhoto; 

set 

this.employeePhoto = value; 

}

1. Question: how to over come this issue.
I have found this link http://www.telerik.com/help/openaccess-orm/openaccess-tasks-howto-explicit-change-tracking.html , but m confuse where exactly i shall write this mentioned codes.

2. How does OpenAccess handle FileStream? 
Thank you!

4 Answers, 1 is accepted

Sort by
0
Ralph Waldenmaier
Telerik team
answered on 06 Mar 2012, 09:30 AM
Hi Gopal,

When working with arrays, you will always get the warning message you reported by default. You can disable this warning message by setting the VerboseMode for the OpenAccess Enhancer to 2 in the OpenAccess.targets file. See the following example:

<Target Name="OpenAccessEnhancer" Inputs="@(IntermediateAssembly->'%(FullPath)')" Outputs="@(EnhancementInfoFile)">
    <OpenAccessEnhancer VerboseMode="2" Assembly="@(IntermediateAssembly->'%(FullPath)')" XmlMapping="@(OpenAccessEmbeddedResource)" AttributeMapping="$(CalculatedAttributeMapping)" FluentMapping="$(CalculatedFluentMapping)" KeyFile="$(AssemblyOriginatorKeyFile)" KeyContainer="$(KeyContainerName)" References="@(ReferencePath)" TargetFramework="$(TargetFrameworkVersion)">
        <Output TaskParameter="Version" ItemName="EV"/>
    </OpenAccessEnhancer>
    <Touch AlwaysCreate="true" Files="@(EnhancementInfoFile)" Time="%(IntermediateAssembly.ModifiedTime)"/>
    <Message Text="@(EV)"/>
</Target>

You can find the OpenAccess.targets file under C:\Program Files (x86)\MSBuild . Hence you need to reload your solution and rebuild your project in order to have the new settings applied. 

To you first question. As mentioned in the documentation you need to inform Telerik OpenAccess ORM about changes to the array, if you manipulate the values inside an array. This is because we can not track these changes. To notify OpenAcces about changes for the field, you must call the MakeDirty() method of the Context/Scope. See the following example:
using (EntitiesModel ctx = new EntitiesModel())
{
    DomainClass1 dc1 = ctx.DomainClass1.First();
    ctx.MakeDirty(dc1, "_property1");
    dc1.Property1[0] = 1;
    ctx.SaveChanges();
}
 If you just replace the whole array, then you don't need to notify OpenAccess about changes you have made because they are tracked automatically.

To your second question: This feature is currently not supported with Telerik OpenAccess ORM. How important is this feature for you?

I hope this information is helpful for you. Do come back if you have any other question.

All the best,
Ralph
the Telerik team
Telerik OpenAccess ORM Q1 2012 release is here! Check out what's new or download a free trial >>
0
Michael
Top achievements
Rank 1
answered on 11 Aug 2014, 07:55 PM
I'm having the same problem as Gopal as well.
Except when I try to change:

VerboseMode="2"

And save the file afterwards to overwrite the old one, it tells me "Access is denied".
Anyone know how I can override it?

Thanks!
0
Kristian Nikolov
Telerik team
answered on 13 Aug 2014, 03:43 PM
Hello Michael,

Thank you for contacting us.

The recommended approach to altering the behavior of the Enhancer would be to make the modification in the MsBuild script of the .csproj or .vbproj file of the project containing your model. You can do this with the following steps:
  1. Right-click on the project and select the Unload Project option.
  2. Right-click on the unloaded project and select the Edit <ProjectName> option.
  3. Nearly at the end of the MsBuild script you will see the import of the OpenAccess.targets file. Before this import, add a new PropertyGroup element containing the EnhancerVerboseMode setting:
    <PropertyGroup>
      <EnhancerVerboseMode Condition="'$(EnhancerVerboseMode)'==''">2</EnhancerVerboseMode>
    </PropertyGroup>

After saving and reloading the project you should no longer see the warning when rebuilding.


I hope this helps. Should you have any more questions feel free to get back to us in our forums or using the Ticketing System.

Regards,
Kristian Nikolov
Telerik
 
OpenAccess ORM is now Telerik Data Access. For more information on the new names, please, check out the Telerik Product Map.
 
0
Catalin
Top achievements
Rank 1
answered on 19 Apr 2016, 10:58 AM

Hi,

I have the same problem as mentioned before, however I get the warning even when the table is marked as readonly:

var cfgBinaryObj = new MappingConfiguration<BinaryObject>();
cfgBinaryObj.HasProperty(x => x.Id).IsIdentity();
cfgBinaryObj.MapType(x => new
{
  Data = x.Data
})
.WithDataAccessKind(DataAccessKind.ReadOnly).ToTable("BinaryObject");

 

where the binary object is like this:

public class BinaryObject
{
  public int Id { get; set; }
  public byte[] Data { get; set; }
}

For the read-only field there is no need for change tracking therefore the warning is unnecessary. Can I still disable the warning without changing the verbosity?

If I disable the warning by changing the verbose mode, wouldn't I loose other significant warnings as well?

Greetings

Catalin

 

 

Tags
Databases and Data Types
Asked by
Gopal
Top achievements
Rank 1
Answers by
Ralph Waldenmaier
Telerik team
Michael
Top achievements
Rank 1
Kristian Nikolov
Telerik team
Catalin
Top achievements
Rank 1
Share this question
or