downloading right now....  ASAP I get a clue, I tell you.

bye

2016-05-13 0:06 GMT-03:00 Praveen Liyanaarachchi <
[email protected]>:

> Thank you very much. I have created sample project and also included a
> readme file how to setup the environment, hope my readme file is clear
> enough .
> Please download the sample project from here
> <https://www.dropbox.com/s/sdwynohesbqeni5/NHTest.zip?dl=0>
>
> On Monday, May 9, 2016 at 7:56:07 PM UTC+9, Praveen Liyanaarachchi wrote:
>
>> Hello,
>> I just trying to access data using *FluentNhibernate* / C# and i got
>> following error message when i trying to execute a sql query. I would
>> appreciate any help
>>
>> Exception: NHibernate.Exceptions.GenericADOException: Unable to perform
>>> find[SQL: SQL not available] ---> System.ArgumentException: The value
>>> "SampleProject.User" is not of type "SampleProject.User" and cannot be used
>>> in this generic collection. Parameter name: value at
>>> System.ThrowHelper.ThrowWrongValueTypeArgumentException(Object value, Type
>>> targetType) at
>>> System.Collections.Generic.List`1.System.Collections.IList.Add(Object item)
>>> at NHibernate.Util.ArrayHelper.AddAll(IList to, IList from)
>>> at NHibernate.Impl.SessionImpl.List(CriteriaImpl criteria, IList
>>> results) --- End of inner exception stack trace --- at
>>> NHibernate.Impl.SessionImpl.List(CriteriaImpl criteria, IList results) at
>>> NHibernate.Impl.CriteriaImpl.List(IList results) at
>>> NHibernate.Impl.CriteriaImpl.ListT
>>
>>
>>
>> my scripts are looks like follows.Seems like something wrong with
>> FluentMappings
>>
>> namespace SampleProject{public class NHibernateHelper{
>>     public NHibernateHelper()
>>     {
>>         InitializeSessionFactory();
>>     }
>>     private static ISessionFactory m_SessionFactory;
>>     public static ISessionFactory SessionFactory
>>     {
>>         get
>>         {
>>             if (m_SessionFactory == null)
>>                 InitializeSessionFactory();
>>             return m_SessionFactory;
>>         }
>>     }
>>     private static void InitializeSessionFactory()
>>     {
>>         try
>>         {
>>             string connectionString = "";
>>             connectionString = 
>> "Server=localhost;Port=3306;Database=myDB;Uid=testUser;Pwd=123; Allow Zero 
>> Datetime=true;Convert Zero Datetime=true; CharSet=utf8";
>>             m_SessionFactory = Fluently.Configure().Database(
>>             MySQLConfiguration.Standard
>>             .ConnectionString(connectionString))
>>             .Mappings(m => m.FluentMappings.AddFromAssemblyOf<GetData>())
>>             .ExposeConfiguration(cfg => 
>> cfg.SetProperty("connection.release_mode", "on_close"))
>>             .BuildSessionFactory();
>>         }
>>         catch (FluentConfigurationException e)
>>         {
>>             throw e.InnerException;
>>         }
>>     }
>>
>>     public static ISession OpenSession()
>>     {
>>         return SessionFactory.OpenSession();
>>     }
>> }
>> }
>>
>>
>>
>> public class User{
>>     public virtual int UserID { get; set; }
>>     public virtual string Name { get; set; }}
>> public class UserMap : ClassMap<User>{
>>     public UserMap()
>>     {
>>         Id(x => x.UserID ).Column("user_id");
>>         Map(x => x.Name).Column("name");
>>         Table("User_master");
>>      }}
>>
>>
>> // Execute sql query
>>
>> using (var session = NHibernateHelper.OpenSession()){
>>       using (var transaction = session.BeginTransaction())
>>       {
>>           var userM = session.CreateCriteria<User>("usr").List<User>();
>>
>>
>>       }}
>>
>>
>>
>> --
> You received this message because you are subscribed to the Google Groups
> "nhusers" group.
> To unsubscribe from this group and stop receiving emails from it, send an
> email to [email protected].
> To post to this group, send email to [email protected].
> Visit this group at https://groups.google.com/group/nhusers.
> For more options, visit https://groups.google.com/d/optout.
>

-- 
You received this message because you are subscribed to the Google Groups 
"nhusers" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to [email protected].
To post to this group, send email to [email protected].
Visit this group at https://groups.google.com/group/nhusers.
For more options, visit https://groups.google.com/d/optout.

Reply via email to