Вопрос

I have using self tracking entities and I do the following:

1.- I create a new entity

2.- I modify one of its properties, for example entityName="Dummy"

After the modification, the state of the entity is still unchanged, so when I do the applychanges it does anything.

I try to set its state to modified, and then it saves the changes in the database. But in this way, I have a problem, because if I am not wrong, STE implement the INotifyPropertyChanged interface, so when I modify a property, is notify and this is a feature that I would like to have.

I am wrong? Perhaps when I change a property the entity it would not be changed its state.

Thanks. Daimroc.

EDIT: this problem also occurs when I get the entities when I consume a WCF service which send me the results of a query to a database using EF 4.0.

EDIT2: I found my error.

The problems is that I have a dll project in which I have the tt file and the Self tracking entities.

I have a WCF service that has a reference to this project. This Service use a repository that use EF to access to the database.

I have a self host application in which I host the WCF service. This application has not a reference to the dll with the STE.

I use svcutil to create the service.cs.

I have the client, in which I add the service.cs. How the service.cs has the classes of my dll project with the STE. But there is a problem, this classes does not have all of this classes. I mean that for example has the ChangeTracker property, but their has not the MarkAs method and others.

So if I edit the service.cs to change the namespace in which is declared my classes and add a reference to the project with the STE classes, the I have access to all methods and also works as I expected.

So the problem is in the "STE classes" of my service, not in the STE classes of my dll project.

Why when I generate the service.cs don't generate the "complete classes"? This makes me add a reference to my dll project with the STE and edit the service.cs to delete the code with its STE classes that don't work as I expect. is there any way to have in the service.cs file the "good STE classes"?

Thanks. Daimroc.

The problem is that I have a WCF service that I host in an WPF application. I run the self host application and with svcutil I create the Service.cs.

I add this Service.cs in my client application. In this Service.cs exists my

Это было полезно?

Решение

Your description is too confusing.

STEs make tight coupling between you service and the client. The only correct way to use STEs is to place them to separate assembly and share this assembly between client and service. When you create service reference for the client application with svcutil.exe you can use reference parameter to specify that assembly for type resolution instead of creating new non STEs types (VS UI for adding service reference offers similar configuration).

Лицензировано под: CC-BY-SA с атрибуция
Не связан с StackOverflow
scroll top