Hello everyone, this is my first post and I apologize in advance if
you have posts on this subject, for I am trying out active record to
evaluate its use in our organization.
The error I receive is "Could not perform Save for LogOnAccess"
I am trying to do a simple record add to the LogOnAccess Activerecord
class. Not a very descriptive message.
Here are the class templates and followed by the code that was
executed.
[ActiveRecord("Application")]
public partial class Application : ApplicationSecurity<Application>//
ActiveRecordBase<Application>
{
#region Field Names
public const string ApplicationIDFieldName = "ApplicationID";
public const string ApplicationNameFieldName = "ApplicationName";
public const string LogAccessFieldName = "LogAccess";
#endregion //Field Names
#region Constructors
public Application() {}
#endregion
#region Properties
[PrimaryKey(Generator=PrimaryKeyType.Identity,
Column=ApplicationIDFieldName)]
public virtual int ApplicationID { get; set; }
[Property(ApplicationNameFieldName,
ColumnType="String" ,NotNull=false )]
public virtual string ApplicationName { get ; set; }
[Property(LogAccessFieldName, ColumnType="Boolean" ,NotNull=false )]
public virtual bool LogAccess { get ; set; }
[HasMany(typeof(GroupSecurity), Table="GroupSecurity",
ColumnKey="ApplicationID", Lazy = true)]
public IList<GroupSecurity> GroupSecurityList { get; set; }
[HasMany(typeof(LogOnAccess), Table="LogOnAccess",
ColumnKey="ApplicationID", Cascade =
ManyRelationCascadeEnum.AllDeleteOrphan,Lazy = true)]
public IList<LogOnAccess> LogOnAccessList { get; set; }
#endregion
[ActiveRecord("LogOnAccess")]
public partial class LogOnAccess : ApplicationSecurity<LogOnAccess>//
ActiveRecordBase<LogOnAccess>
{
#region Field Names
public const string LogOnAutoIDFieldName = "LogOnAutoID";
public const string UserNameFieldName = "UserName";
public const string LogOnDateFieldName = "LogOnDate";
#endregion //Field Names
#region Constructors
public LogOnAccess() {}
#endregion
#region Properties
[PrimaryKey(Generator=PrimaryKeyType.Native,
Column=LogOnAutoIDFieldName)]
public virtual int LogOnAutoID { get ; set; }
[Property(UserNameFieldName, ColumnType="AnsiChar" ,NotNull=false )]
public virtual string UserName { get ; set; }
[Property(LogOnDateFieldName, ColumnType="DateTime" ,NotNull=false )]
public virtual DateTime LogOnDate { get ; set; }
[BelongsTo(Type = typeof(Application), Column = "ApplicationID")]
public Application Application { get; set; }
I am calling this from the following class.
#region Fields
private string appName;
private Application _applications;
#endregion
#region Constructors
public AuthenticationLogic()
{
appName = ConfigurationManager.AppSettings["ProgramName"];
string[] appNames = { appName };
_applications = Application.FindOne(DetachedCriteria.For<Application>
()
.Add(Expression.In("ApplicationName", appNames)));
}
#endregion
public IList<GroupSecurity> GetAuthorizedGroups()
{
try
{
if (_applications != null)
{
System.Web.HttpContext.Current.Session.Add("LogUsers",
_applications.LogAccess.ToString());
return _applications.GroupSecurityList;
}
}
catch
{
//TODO: enable logging functionality
//logging functionality
throw;
}
return null;
}
public bool InsertLogOnAccess(string username)
{
try
{
LogOnAccess _La = new LogOnAccess();
_La.UserName = username;
_La.Application = _applications;
_La.Save();
return true;
}
catch (Exception ex)
{
//TODO: enable logging functionality
//logging functionality
throw;
}
return false;
}
on _La.Save(); the exception is being throw. I would really appreciate
it if someone could tell me what I am doing wrong.
Innerexception: at NHibernate.Type.BaseCharType.Set(IDbCommand cmd,
Object value, Int32 index)
at NHibernate.Type.NullableType.NullSafeSet(IDbCommand cmd, Object
value, Int32 index)
at NHibernate.Type.NullableType.NullSafeSet(IDbCommand st, Object
value, Int32 index, Boolean[] settable, ISessionImplementor session)
at NHibernate.Persister.Entity.AbstractEntityPersister.Dehydrate
(Object id, Object[] fields, Boolean[] includeProperty, Boolean[][]
includeColumns, Int32 table, IDbCommand statement, ISessionImplementor
session, Int32 index)
at NHibernate.Persister.Entity.AbstractEntityPersister.Insert(Object
[] fields, Boolean[] notNull, SqlCommandInfo sql, Object obj,
ISessionImplementor session)
stack trace: at Castle.ActiveRecord.ActiveRecordBase.InternalSave
(Object instance, Boolean flush)
at Castle.ActiveRecord.ActiveRecordBase.Save(Object instance)
at Castle.ActiveRecord.ActiveRecordBase.Save()
at LogOnCastle.BLL.AuthenticationLogic.InsertLogOnAccess(String
username) in C:\Visual Studio Projects\LogOnCastle\LogOnCastle\BLL
\AuthenticationLogic.cs:line 87
Thank you in advance
--~--~---------~--~----~------------~-------~--~----~
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
-~----------~----~----~----~------~----~------~--~---