我在Nhibernate3.1中有一个QueryOver方法
var q = SessionInstance.QueryOver<Person>().
Where(person=>person.PersonIdentity.FirstName.IsLike(firstName,MatchMode.Anywhere));
return q.List<Person>();
Run Code Online (Sandbox Code Playgroud)
现在我有这条消息的运行时错误:
无法解析属性:PersonIdentity.FirstName:MyNameSpace.Domain.Entities.Person
为什么?
我有一个使用Enterprise Library.Logging 5,.NET Framework 4.0 Client Profile的WPF应用程序
我使用数据库逻辑记录.还要添加对3个dll的引用以进行投影.
Microsoft.Practices.EnterpriseLibrary.Logging.dll
Microsoft.Practices.EnterpriseLibrary.Logging.Database.dll
Microsoft.Practices.EnterpriseLibrary.Data.dll
Run Code Online (Sandbox Code Playgroud)
logEntry.Write(log)通过此消息我有1个运行时错误:
Invalid TraceListenerData type in configuration 'listenerDataType="Microsoft.Practices.EnterpriseLibrary.Logging.Database.Configuration.FormattedDatabaseTraceListenerData, Microsoft.Practices.EnterpriseLibrary.Logging.Database, Version=5.0.414.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35"'
Run Code Online (Sandbox Code Playgroud)
我的app.config是:
<loggingConfiguration name="" tracingEnabled="true" defaultCategory="General" logWarningsWhenNoCategoriesMatch="false">
<listeners>
<add name="Event Log Listener" type="Microsoft.Practices.EnterpriseLibrary.Logging.TraceListeners.FormattedEventLogTraceListener, Microsoft.Practices.EnterpriseLibrary.Logging, Version=5.0.414.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35"
listenerDataType="Microsoft.Practices.EnterpriseLibrary.Logging.Configuration.FormattedEventLogTraceListenerData, Microsoft.Practices.EnterpriseLibrary.Logging, Version=5.0.414.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35"
source="Enterprise Library Logging" formatter="Text Formatter"
log="" machineName="." traceOutputOptions="None" />
<add name="Database Trace Listener" type="Microsoft.Practices.EnterpriseLibrary.Logging.Database.FormattedDatabaseTraceListener, Microsoft.Practices.EnterpriseLibrary.Logging.Database, Version=5.0.414.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35"
listenerDataType="Microsoft.Practices.EnterpriseLibrary.Logging.Database.Configuration.FormattedDatabaseTraceListenerData, Microsoft.Practices.EnterpriseLibrary.Logging.Database, Version=5.0.414.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35"
databaseInstanceName="Logging" writeLogStoredProcName="WriteLog"
addCategoryStoredProcName="AddCategory" formatter="Text Formatter"
traceOutputOptions="LogicalOperationStack, DateTime, Timestamp" />
</listeners>
<formatters>
<add type="Microsoft.Practices.EnterpriseLibrary.Logging.Formatters.TextFormatter, …Run Code Online (Sandbox Code Playgroud) .net configuration logging enterprise-library enterprise-library-5
可能重复:
在c#中将字符串转换为DateTime
如何通过格式将字符串转换为DateTime?
Convert.ToDateTime("12/11/17 2:52:35 PM")
Run Code Online (Sandbox Code Playgroud)
结果是12/11/2017 02:52:35 PM,这是不正确的,因为我的期望11/17/2012 02:52:35 PM
我有一个使用NHibernate(2.2版)的项目.要升级到NHibernate 3.2,我该怎么办?
在dll之后我需要升级吗?
我需要升级hbm文件吗?我是否需要升级hibernate.cfg.xml文件?
我有一个使用SQL Server 2008中的数据库的Windows应用程序.
我不希望用户看到数据库表.
如何加密数据库中的表?
sql sql-server encryption sql-server-2008 sql-server-2008-r2
我有一个Person继承的类EntityBase:
public class Person : EntityBase
{
virtual public string FirstName { get; set; }
virtual public string LastName { get; set; }
virtual public IList<Asset> Assets { get; set; }
}
Run Code Online (Sandbox Code Playgroud)
和
public class EntityBase : IEntity
{
public virtual long Id { get; protected set; }
public virtual string Error { get; protected set; }
}
Run Code Online (Sandbox Code Playgroud)
我需要获得自习Person类的属性列表:
var entity = preUpdateEvent.Entity;
foreach (var item in entity.GetType().GetProperties()) //only FirstName & LastName
{
if …Run Code Online (Sandbox Code Playgroud) 我有一个使用linq到NHibernate的查询,用于EnterAndExitArchive实体.该实体具有按Archive实体关联.
public EnterAndExitArchive GetLastEnterAndExitArchive(long archiveId)
{
var q = SessionInstance.Query<EnterAndExitArchive>()
.Where(x => x.Archive.Id == archiveId)
.LastOrDefault<EnterAndExitArchive>();
return q;
}
Run Code Online (Sandbox Code Playgroud)
要么
public EnterAndExitArchive GetLastEnterAndExitArchive(long archiveId)
{
var q = SessionInstance.Query<EnterAndExitArchive>()
.LastOrDefault<EnterAndExitArchive>(x => x.Archive.Id == archiveId);
return q;
}
Run Code Online (Sandbox Code Playgroud)
但这有一个运行时错误.异常消息是The LastResultOperator result operator is not current supported.
为什么?
我有一个Address类.
public class Address : RootEntityBase
{
virtual public string Province { set; get; }
virtual public string City { set; get; }
virtual public string PostalCode { set; get; }
}
Run Code Online (Sandbox Code Playgroud)
通过此默认值:
var myList = new List<Address>
{
new Address {Province = "P1", City = "C1", PostalCode = "A"},
new Address {Province = "P1", City = "C1", PostalCode = "B"},
new Address {Province = "P1", City = "C1", PostalCode = "C"},
new Address {Province = "P1", City = "C2", …Run Code Online (Sandbox Code Playgroud) 我有3个类:Person,Employee1,Employee2
public class Employee1 : Person
{
}
public class Employee2 : Person
{
}
Run Code Online (Sandbox Code Playgroud)
我需要查询Person_Table,有时需要加入Employee1_Table或Employee_Table.
var q = SessionInstance.Query<Person>();
if (dto.Code != null) // A1 Condition
q = q.Where(x => x.Code == dto.Code);
//if(A2 Condition)
//if(A3 Condition)
//...
switch (dto.Type)
{
case PersonType.Employee1:
var q1 = SessionInstance.Query<Employee1>();
q.Join(q1, x => x.Id, xx => xx.Id, (x, xx) => x);
if (!String.IsNullOrEmpty(dto.Unit)) // B1 Condition
q1 = q1.Where(xx => xx.Unit == dto.Unit);
//if(B2 Condition)
//if(B3 Condition)
//...
return q1.ToList<Person>();
case PersonType.Employee2: …Run Code Online (Sandbox Code Playgroud) c# ×7
nhibernate ×4
linq ×3
.net ×1
c#-4.0 ×1
compression ×1
datetime ×1
distinct ×1
encryption ×1
format ×1
join ×1
logging ×1
queryover ×1
sql ×1
sql-server ×1
string ×1
zip ×1