Plateforme Level Extreme
Abonnement
Profil corporatif
Produits & Services
Support
Légal
English
Using EF with a view
Message
 
 
À
18/12/2015 04:32:38
Information générale
Forum:
ASP.NET
Catégorie:
Entity Framework
Versions des environnements
Environment:
C# 4.0
OS:
Windows 7
Network:
Windows 2003 Server
Database:
MS SQL Server
Application:
Web
Divers
Thread ID:
01629081
Message ID:
01629100
Vues:
28
>>Right, good point and this is what I've been looking at right now as well. The configuration was created automatically and right now the key is not defined correctly (it is based on all columns in the table). I'll see if re-running the tool will fix that problem.
>>
>>There is another view which also seems to have wrong configuration (instead of a valid key it uses several columns as a key). I think that view works fine, but I haven't been testing it for some time.
>>
>>I'm wondering if with schemabinding is enough to pass the table's key back to the view or I have to change all columns to use cast(col as ..) in order to make them nullable and not keys.
>>
>>UPDATE. With schemabinding didn't work. I'll try casting all columns to proper types to make them nullable and see if it helps.
>>
>>UPDATE. It works without schemabining but I do need to apply the cast trick to make only PK to be PK in the view.
>
>Check this : http://blogs.msdn.com/b/alexj/archive/2009/09/01/tip-34-how-to-work-with-updatable-views.aspx

Thanks. In our case we're using Code First by using Reverse POCO Generator. The solution is to make the view with all nullable columns except for the ID. The simplest way to make a column nullable is to use CAST(Column as ColumnType) as Column. I did implement that solution before as well, just forgot.

I'm thinking that I need to add 2 more methods to our base repository classes to allow to update multiple rows. (Currently I implemented these methods directly in each class repository that needed it - I think I'd rather have them generic).

Right now the base class has the following methods:
public virtual void Update(T entity)
and
public virtual void UpdateView(TList entity)
I want to add similar methods using List< T > entity and List< TList > entity. The only problem right now is to figure out good names for these methods.
If it's not broken, fix it until it is.


My Blog
Précédent
Répondre
Fil
Voir

Click here to load this message in the networking platform