有没有一种简单的方法可以将高速缓存中的实体标记为“已添加"? [英] is there an easy way to mark an entity in the cache as "added"?

查看:51
本文介绍了有没有一种简单的方法可以将高速缓存中的实体标记为“已添加"?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我想将服务器发送的实体设置为添加".看起来entityaspect拥有setdeleted,setmodified等方法...但是我似乎找不到一个叫做setadded的方法...将实体设置为"addended"的最干净方法是什么?我在想,也许我需要先拆下来再装上增加的"字样.我有一个称为"newdeal"的服务器方法,该方法创建了一个可供数据输入的新实体...该方法具有业务逻辑,我希望保留在服务器上...当到达客户端时,该实体被标记为未修改",这是有道理的...但是我想将其更改为添加" ...

i would like to set an entity sent from the server to "added". it looks like entityaspect has methods setdeleted, setmodified, etc... but i can't seem to find one called setadded... what is the cleanest way to set an entity to "added"? i was thinking perhaps i would need to detach and then attach as "added". i have a server method called "newdeal" which creates a new entity ready for data entry... this method has business logic which i would prefer to keep on the server... when it gets to the client the entity is marked as "unmodified" which makes sense... but i would then like to change it to "added"...

谢谢

推荐答案

@giancarloa,我假设当实体从服务器发送到客户端时,该实体已保存在数据库中.如果是这种情况,将其entityState设置为Added将没有任何意义,因为这将导致重复的错误.如果那不是它的工作原理,请在我试图了解您正在采取的所有步骤时,详细说明您的工作.

@giancarloa, I'm assuming that, by the time the entity is sent from server to client, it has been persisted in the database. If that's the case, it wouldn't make sense to have its entityState set to Added as it would cause a duplicate error. If that's not how it works, please explain in detail what you are doing as I'm trying to get an idea of all the steps you're taking.

对于为什么要在服务器中创建实体,将其发送给客户端,对其进行更新,然后再将其发送回服务器以将其保存到数据库中,我也感到困惑-这似乎会引起更多的流量,并且可能会降低性能.另外,用户决定不保存什么?-那么服务器上的工作就被浪费了.

I'm also confused as to why create an entity in the server, send it to the client, update it, and then send it back to the server to save it in the DB - this just appear to cause more traffic and possibly reduce performance. Also, what it the user decides not to save? - then the work in the server would've been wasted.

为什么不在客户端中创建实体,如果事实证明该实体已保存,那么业务逻辑将在beforeSaveEntity/beforeSaveEntities期间在服务器中启动?

Why not create the entity in the client and if it turns out to be saved, then the business logic would kick in the server during the beforeSaveEntity/beforeSaveEntities?

这篇关于有没有一种简单的方法可以将高速缓存中的实体标记为“已添加"?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
相关文章
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆