Glad to hear. Don't forget to read http://nhforge.org/doc/nh/en/index.html;-)

On Tue, Sep 15, 2009 at 8:41 PM, Gustavo Melo <[email protected]> wrote:

> Roelof,
>
> Works perfect...
>
> *Thank you all of you guys for your time.*
>
>
> On Tue, Sep 15, 2009 at 3:18 PM, Roelof Blom <[email protected]>wrote:
>
>> For executing DML you'll have to use NH Session directly to create the HQL
>> query and call ExecuteUpdate() on it.
>>
>> When  using ActiveRecord you can obtain a NH session like this:
>>
>> var session = SessionScope.Current.GetSession(typeof (ActiveRecordBase));
>> ,or
>> var session =
>> ActiveRecordMediator.GetSessionFactoryHolder().CreateSession(typeof(User))
>>
>> and then session.CreateQuery("update User usr set usr.Login= 'Test' ").*
>> ExecuteUpdate()*;
>>
>> -- Roelof.
>>
>>
>> On Tue, Sep 15, 2009 at 5:24 PM, Gustavo Melo <[email protected]> wrote:
>>
>>> Gerdus,
>>>
>>> Thanks for your reply...
>>>
>>> But now...
>>> *Not supported for DML operations*I try find some on web (Ayende Blog)
>>> but it's very hard to make this work...
>>>
>>> I have a reference of Antlr3.Runtime.dll on my project.
>>>
>>> I almost given up :(
>>>
>>> On Tue, Sep 15, 2009 at 11:45 AM, Gerdus van Zyl <[email protected]
>>> > wrote:
>>>
>>>>
>>>> I think it should be:
>>>>
>>>> SimpleQuery query = new SimpleQuery(typeof(User), "update User usr set
>>>> usr.Login= 'Test' ");
>>>>
>>>> Case matters and you have to use the defined property name.
>>>>
>>>> ~Gerdus
>>>>
>>>> On Tue, Sep 15, 2009 at 4:16 PM, Gustavo Melo <[email protected]>
>>>> wrote:
>>>> > Thanks Gauthier,
>>>> >
>>>> > But i'm still have a trouble with that...
>>>> >
>>>> > I try something like that:
>>>> >
>>>> > [ActiveRecord("user")]
>>>> > public class User : ActiveRecordBase
>>>> > {
>>>> >        [PrimaryKey(PrimaryKeyType.Assigned, "usu_id")]
>>>> >        public string Id { get; set; }
>>>> >
>>>> >        [Property("name", NotNull = true)]
>>>> >        public string Login { get; set; }
>>>> >
>>>> >         public void updateAllUsers()
>>>> >         {
>>>> >             SimpleQuery query = new SimpleQuery(typeof(User), "update
>>>> user
>>>> > set name = Test");
>>>> >
>>>> >             ExecuteQuery(query);
>>>> >         }
>>>> > }
>>>> >
>>>> > When i call updateAllUsers: Could not perform ExecuteQuery for Usuario
>>>> >
>>>> > user is not mapped [update user set name = 'Test']
>>>> >
>>>> > All CRUD's operations work fine, but i don't know how to use HQL.
>>>> >
>>>> >
>>>> > On Tue, Sep 15, 2009 at 2:38 AM, Gauthier Segay <
>>>> [email protected]>
>>>> > wrote:
>>>> >>
>>>> >> Best way is executing an update HQL statement:
>>>> >>
>>>> >>
>>>> >>
>>>> http://ayende.com/Blog/archive/2009/05/28/nhibernate-ndash-executable-dml.aspx
>>>> >>
>>>> >> using the execute callback is the straight forward way:
>>>> >>
>>>> >>
>>>> >>
>>>> http://www.castleproject.org/ActiveRecord/documentation/v1rc1/usersguide/hql.html
>>>> >>
>>>> >> On Sep 14, 9:43 pm, Gustavo Melo <[email protected]> wrote:
>>>> >> > I have a table (user)
>>>> >> >
>>>> >> > [ActiveRecord("user")]
>>>> >> > public class User : ActiveRecordBase
>>>> >> > {
>>>> >> >         [PrimaryKey(PrimaryKeyType.Assigned, "usu_id")]
>>>> >> >         public string Id { get; set; }
>>>> >> >
>>>> >> >         [Property("name", NotNull = true)]
>>>> >> >         public string Login { get; set; }
>>>> >> >
>>>> >> > }
>>>> >> >
>>>> >> > How do i update all users in the table for name = "Test" ?
>>>> >> >
>>>> >> > I didn't find on web or documantation...
>>>> >> >
>>>> >> > Some1 can help me?
>>>> >> >
>>>> >> > Best Regards
>>>> >>
>>>> >
>>>> >
>>>> >
>>>> > --
>>>> > Analista Desenvolvedor
>>>> > www.espacodj.com
>>>> >
>>>> > >
>>>> >
>>>>
>>>>
>>>>
>>>
>>>
>>> --
>>> Analista Desenvolvedor
>>> www.espacodj.com
>>>
>>>
>>>
>>
>>
>>
>
>
> --
> Analista Desenvolvedor
> www.espacodj.com
>
> >
>

--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups 
"Castle Project Users" group.
To post to this group, send email to [email protected]
To unsubscribe from this group, send email to 
[email protected]
For more options, visit this group at 
http://groups.google.com/group/castle-project-users?hl=en
-~----------~----~----~----~------~----~------~--~---

Reply via email to