how to save a property directly to db with a part?

Topics: General
Sep 19, 2011 at 6:55 PM

i search this question in this site and got something like this :

" If you need to access records directly, use IRepository<YourDesiredRecord>. It's a low-level mean of database access and you can do any queries Linq-to-NHibernate allows you to.

But if you are creating your own content type (with some custom content part on it, I suppose) you'd rather stick to IContentManager and it's Query method. It's a better way to go in this case. Querying the IRepository will get you only the raw database records, but content manager will return the full content items (with all parts it has). "

my situation is : i have two data(properties) latitude and longitude which i got from client side,( already know), so i do not need admin board to save , i want to save them to db  automatically   with user Part (or connected to user part in a way)

thanks for any help

andy

Coordinator
Sep 19, 2011 at 6:59 PM
Edited Sep 19, 2011 at 7:00 PM

I would create a service class that exposes methods to interact with your external database, and I'd call into that from the display and editor (post overload) methods of the driver for the part. This should work just fine. You will probably have to opt out of the Orchard ambient transaction (do a search on that in this forum).

Coordinator
Sep 19, 2011 at 7:01 PM

oh, and also, of course, don't wire up a repository from the handler as you usually would.