I was also doing some more diggin and I've found that the insert goes
through correctly the first time but then an update is run shortly after
that nulls out the values.


Person Class:

using System;
using System.Collections;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using Castle.ActiveRecord;
using NHibernate.Engine;

namespace ActiveRecord.Models
{
    [ActiveRecord]
    public class Person : ActiveRecordBase
    {
        private int id;
        private string name;
        private String funfact;
       // private IList activities = new ArrayList();

        public Person()
        {

        }

        public Person(string name)
        {
            this.name = name;
        }

        [PrimaryKey]
        public int Id
        {
            get { return id; }
            set { id = value; }
        }

        [Property]
        public string Name
        {
            get { return name; }
            set { name = value; }
        }

        [Property]
        public String FunFact
        {
            get { return funfact; }
            set { name = value; }
        }

      //  [HasMany(typeof(Activity),
      //      Table = "Activities", ColumnKey = "person_id",
      //      Inverse = true, Cascade =
ManyRelationCascadeEnum.AllDeleteOrphan)]
      //  public IList Activities
      //  {
      //      get { return activities; }
      //      set { activities = value; }
      //  }

        public static void DeleteAll()
        {
            DeleteAll(typeof (Person));
        }

        public static Person[] FindAll()
        {
            return (Person[]) FindAll(typeof (Person));
        }

        public static Person Find(int id)
        {
            return (Person) FindByPrimaryKey(typeof(Person), id);
        }
    }
}

On Mon, Mar 8, 2010 at 11:22 AM, Nicholas Kilian <
[email protected]> wrote:

>  Can you post your Person class to show the AR attributes?
>
>
>
> *From:* [email protected] [mailto:
> [email protected]] *On Behalf Of *Kevin Pratt
> *Sent:* 08 March 2010 08:03 AM
> *To:* [email protected]
> *Subject:* Objects being created will all properties null
>
>
>
> Hello
>
>
>
> I'm trying out ActiveRecord for the first time and I am having some
> trouble.
>
>
>
> When I instantiate a new model and then call create a record is created in
> the database but all the properties are set to null.
>
>
>
> Example code:
>
>
>
>             var person = new Person {Name = "Kevin"};
>
>             person.Name = "kevin";
>
>             person.Create();
>
>
>
>             FlushAndRecreateScope();
>
>
>
>             Person[] people = Person.FindAll();
>
>             Assert.AreEqual(1,people.Length);
>
>             Assert.AreEqual("Kevin",people[0].Name);
>
>
>
> The FlushAndRecreateScope method is from the unit test example at :
> http://www.castleproject.org/activerecord/documentation/v1rc1/usersguide/unittesting.html
>
>
>
> I've used both sqlite and mssqlce to test with.
>
>
>
> My app.config file is as follows:
>
>
>
> <?xml version="1.0" encoding="utf-8" ?>
>
> <configuration>
>
>  <configSections>
>
>         <section name="activerecord"
>
>
> type="Castle.ActiveRecord.Framework.Config.ActiveRecordSectionHandler,
> Castle.ActiveRecord" />
>
>     </configSections>
>
>
>
>     <activerecord
>
>        isDebug="true">
>
>       <!--
>
>       <config>
>
>         <add key="connection.provider"
>
>              value="NHibernate.Connection.DriverConnectionProvider" />
>
>         <add key="dialect"
>
>              value="NHibernate.Dialect.MsSqlCeDialect" />
>
>         <add key="connection.driver_class"
>
>              value="NHibernate.Driver.SqlServerCeDriver" />
>
>         <add key="connection.connection_string"
>
>              value="Data Source=D:\Databases\test.sdf" />
>
>         <add key="proxyfactory.factory_class"
>
>
> value="NHibernate.ByteCode.Castle.ProxyFactoryFactory,NHibernate.ByteCode.Castle"/>
>
>         <add key="show_sql"
>
>              value="true" />
>
>       </config>
>
>       -->
>
>       <config>
>
>         <add key="connection.provider"
>
>              value="NHibernate.Connection.DriverConnectionProvider" />
>
>         <add key="dialect"
>
>              value="NHibernate.Dialect.SQLiteDialect" />
>
>         <add key="connection.driver_class"
>
>              value="NHibernate.Driver.SQLite20Driver" />
>
>         <add key="connection.connection_string"
>
>              value="Data Source=D:\Databases\test.db" />
>
>         <add key="proxyfactory.factory_class"
>
>
> value="NHibernate.ByteCode.Castle.ProxyFactoryFactory,NHibernate.ByteCode.Castle"/>
>
>         <add key="show_sql"
>
>              value="true" />
>
>       </config>
>
>
>
>     </activerecord>
>
> </configuration>
>
>
>
>
>
> Also I am configuring the system using the IConfigureSource method:
>
>
>
>             IConfigurationSource source =
> ActiveRecordSectionHandler.Instance;
>
>
>
>             //ActiveRecordStarter.Initialize(source);
>
>
>  ActiveRecordStarter.Initialize(Assembly.Load("ActiveRecord"),source);
>
>
>
> My project's name is ActiveRecord.
>
>
>
> If anyone has any insight as to why this would be happening I would love to
> hear it!.
>
>
>
> Thanks
>
>
>
> Kevin Pratt
>
> --
> 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]<castle-project-users%[email protected]>
> .
> For more options, visit this group at
> http://groups.google.com/group/castle-project-users?hl=en.
>
> --
> 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]<castle-project-users%[email protected]>
> .
> For more options, visit this group at
> http://groups.google.com/group/castle-project-users?hl=en.
>

-- 
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