Pasting classes here since attachments are rejected:

/* Moduledata.cs classes */
using Castle.ActiveRecord;
using System;

namespace Avi.Engine
{
    [ActiveRecord(Table = "ModuleData", Lazy = false)]
    public class ModuleData : ActiveRecordBase<ModuleData>
    {
        [PrimaryKey(Generator = PrimaryKeyType.Native)]
        public int Id { get; set; }
        [Property]
        public string MobileNumber { get; set; }
        [Property]
        public DateTime EnteredDate { get; set; }
        [Property]
        public string ModuleId { get; set; }
        [Property]
        public string PhcSubcenter { get; set; }
        [Property]
        public int Value { get; set; }
    }
}

/* This is what is called when I initialize */
public void ActiveRecord_Init()
        {
            if (!ActiveRecordStarter.IsInitialized)
            {
                // Get environment and connection string from web.config
                string environment =
ConfigurationManager.AppSettings["Environment"];
                string connectionString = string.Empty;
                switch (environment.ToLower())
                {
                    case "prod":
                        connectionString =
ConfigurationManager.ConnectionStrings["avi-prod"].ConnectionString;
                        break;

                    default:
                    case "dev":
                    case "ppe":
                        connectionString =
ConfigurationManager.ConnectionStrings["avi-ppe"].ConnectionString;
                        break;
                }

                var properties = new Dictionary<string, string>();
                properties.Add("connection.driver_class",
"NHibernate.Driver.MySqlDataDriver");
                properties.Add("dialect",
"NHibernate.Dialect.MySQLDialect");
                properties.Add("connection.provider",
"NHibernate.Connection.DriverConnectionProvider");
                properties.Add("connection.connection_string",
connectionString);
                properties.Add("proxyfactory.factory_class",
"NHibernate.ByteCode.Castle.ProxyFactoryFactory,
NHibernate.ByteCode.Castle");

                InPlaceConfigurationSource source = new
InPlaceConfigurationSource();
                source.Add(typeof(ActiveRecordBase), properties);

                if (!ActiveRecordStarter.IsInitialized)
                {
                    ActiveRecordStarter.Initialize(source,
                        typeof(Avi.Engine.CellId),
                        /* typeof(Avi.Engine.AppError), */
                        typeof(Avi.Engine.FieldUser),
                        typeof(Avi.Engine.ModuleData),
                        typeof(Avi.Engine.RawIncomingSms));
                }

                try
                {
                    if (SessionFactory == null)
                    {
                        var config = new NHibernate.Cfg.Configuration();
                        config.Configure();
                        config.AddAssembly("Avi.Engine");
                        /*config.AddClass(typeof(Avi.Engine.ModuleData));
                        config.AddClass(typeof(Avi.Engine.CellId));
                        config.AddClass(typeof(Avi.Engine.FieldUser));

 config.AddClass(typeof(Avi.Engine.RawIncomingSms));*/
                        SessionFactory = config.BuildSessionFactory();
                    }
                }
                catch (System.Exception ex)
                {

                }
            }
        }

--Am


2011/2/5 maumad <[email protected]>

> Sorry that I was ambiguous. Here is code in details:
>
> I have attached the Module data class file. And this is the query I want to
> execute:
>
> ActiveRecordContext.Instance.SessionFactory.OpenSession())
> {
>     var list = session.CreateCriteria<ModuleData>().List<ModuleData>();
> }
>
> I have also attached the ActiveRecordContext file where I initialize the
> classes.
>
>  Let me know if I am doing anything wrong. Basically, the query is not
> generated when watched under NHibernate Profiler.
>
> Thanks!
> --Am
>
>
> 2011/2/3 José F. Romaniello <[email protected]>
>
> please, show your classes. and the query your want to execute. I don't
>> understand your problem.
>>
>> 2011/2/1 maumad <[email protected]>
>>
>>> Commenting that out does not help either. Code is reduced just to 2 lines
>>> now:
>>>
>>> ActiveRecordContext.Instance.SessionFactory.OpenSession())
>>> {
>>>     var list = session.CreateCriteria<ModuleData>().List<ModuleData>();
>>> }
>>>
>>> Now my suspicion is on session object. How can I make sure it is correct?
>>>
>>> To verify, I tried: ?session.Get<CellId>(01010101)
>>>
>>> I get MappingException Unhandled. {"No persister for:
>>> Avi.Engine.CellId"}.
>>>
>>> But when I try to get the value by calling following code: I do get the
>>> CellId object back.
>>>
>>> CellId.FindOne(Expression.Eq("Id", 01010101));
>>>
>>> I do not have any xml mappings files. Is it necessary for session object
>>> to be created?
>>>
>>> Thanks for reading through all this. Your help is appreciated.
>>>
>>> --Am
>>>
>>>
>>> 2011/2/1 José F. Romaniello <[email protected]>
>>>
>>> I think you dont have to set the projection on the id.
>>>>
>>>>
>>>> 2011/2/1, maumad <[email protected]>:
>>>> > I am trying to get very simple query working. It does not throw but
>>>> > returns empty list. Here is the query:
>>>> >
>>>> >             using (var session =
>>>> > ActiveRecordContext.Instance.SessionFactory.OpenSession())
>>>> >             {
>>>> >                 var query1 = session.CreateCriteria<ModuleData>();
>>>> >                 query1.SetProjection(Projections.Property("Id"));
>>>> >                 query1.Add(Expression.Ge("Id", 0));
>>>> >                 var list = query1.List<ModuleData>();
>>>> >             }
>>>> >
>>>> > If I write HqlBasedQuery it works fine:
>>>> >
>>>> > var query = new HqlBasedQuery(typeof(ModuleData),
>>>> >                 QueryLanguage.Sql,
>>>> >                 @"SELECT Id
>>>> >                     FROM `aviprod`.`ModuleData`
>>>> >                     WHERE Id > '0'");
>>>> >
>>>> > Any pointers?
>>>> >
>>>> > --
>>>> > 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.
>>>> >
>>>> >
>>>>
>>>> --
>>>> Enviado desde mi dispositivo móvil
>>>>
>>>> --
>>>> 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.
>>>>
>>>>
>>>  --
>>> 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.
>>>
>>
>>  --
>> 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.
>>
>
>

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