데이터베이스에 연결된 wcf 서비스를 만들려고합니다. 연결을 위해 NHibernate를 사용하고 있습니다.NHibernate ICriteria null을 반환합니다
[DataContract]
public class Course
{
private int ccode;
private string cname;
private int credits;
[DataMember]
public int CCode
{
get
{
return ccode;
}
set
{
ccode = value;
}
}
etc...
}
모든 재산 위 클래스 (모두 getter와 setter로) 속성 DataMember를가했습니다 여기에는 파일 rsultMngSystmMapper.hbm.xml에 매핑되는 클래스 코스입니다. 이제 파일 rsultMngSystmMapper.hbm.xml :
<?xml version="1.0" encoding="utf-8" ?>
<hibernate-mapping xmlns="urn:nhibernate-mapping-2.2"
assembly="RManageSystemService"
namespace="RManageSystemService.orm_rman_systm">
<class name="Course" table="Courses" lazy="false">
<id name="CCode" column="ccode">
<generator class="identity"/>
</id>
<property name="CName" column="cname"/>
<property name="Credits" column="credit"/>
</class>
</hibernate-mapping>
이제 파일은 hibernate.cfg.xml :
<?xml version="1.0" encoding="utf-8" ?>
<hibernate-configuration xmlns="urn:nhibernate-configuration-2.2">
<session-factory>
<property name="connection.provider">NHibernate.Connection.DriverConnectionProvider</property>
<property name="dialect">NHibernate.Dialect.MsSql2012Dialect</property>
<property name="connection.driver_class">NHibernate.Driver.SqlClientDriver</property>
<property name="connection.connection_string">Data Source=Mnemonics;User ID=Mnmncs;Password=mnmncs;Initial Catalog=database-name;Integrated Security=true</property>
<property name="show_sql">true</property>
<mapping assembly="RManageSystemService"/>
</session-factory>
</hibernate-configuration>
내가 대신의 Web.config에 위의 코드를 삽입해야 하는가? 아니면 그것을 분리 시켜도 괜찮습니까?
지금 클래스 RMngrDataManipulation이 지금까지이 클래스에있는 유일한 방법입니다 :
public static Course RetrieveData(Course c)
{
Configuration myConfig;
ISessionFactory mySessFac;
ISession mySess;
myConfig = new Configuration();
myConfig.Configure(Path.Combine(AppDomain.CurrentDomain.BaseDirectory, "hibernate.cfg.xml"));
mySessFac = myConfig.BuildSessionFactory();
mySess = mySessFac.OpenSession();
try
{
ICriteria criteria = mySess.CreateCriteria<Course>();
IList<Course> cList = criteria.List<Course>();
foreach (Course course in cList)
{
c = course;
}
//This one is empty
return c;
}
catch (Exception e)
{
throw;
}
finally
{
if (!mySessFac.IsClosed)
{
mySessFac.Close();
}
}
}
내가 얻을 결과 I 클래스 CourseService.svc.cs에서 방법 RetrieveData()를 호출 할 때 WCF 테스트 클라이언트에서이
을 따르는 것을 내가 미스가 있습니까 에드? 내 매핑 파일이 맞습니까? 나는 너희들의 의견에 대해 매우 감사 할 것이다.편집 : 유형 'System.IO.DirectoryNotFoundException'의 첫 번째 예외가 mscorlib.dll
EDIT2 (2014년 12월 27일, 17.51)
발생 :이 메시지를 찾을 VS2012에서 출력 탭을 보면,745,151 사실을 바탕으로[this_.ccode를 ccode2_0_으로 선택하고 this_.cname을 cname2_0_, this_.credit을 credit2_0_에서 코스 this_] [SQL : this_.ccode를 ccode2_0_, this_.cname을 cname2_0_으로 선택, this_.credit as credit2_0_ FROM Courses this_] 서버 스택 추적 : vid System.ServiceModel.Channels.ServiceChannel.ThrowIfFaultUnderstood (메시지 응답, MessageFault 오류, 문자열 동작, 메시지 System.ServiceModel.Channels.ServiceChannel.HandleReply (ProxyOperationRuntime 작업, ProxyRpc & rpc) vid System.ServiceModel.Channels.ServiceChannel.Call (String 액션, 부울 oneway, ProxyOperationRuntime 작업, Object [] ins, Object) [] outs, TimeSpan timeout) vid System.ServiceModel.Channels.ServiceChannelProxy.InvokeService (IMethodCallMessage methodCall, ProxyOperationRuntime operation) vid System.ServiceModel.Channels.ServiceChannelProxy.Invoke (IMessage message) [0]에서 rethrown 된 예외입니다. vid System.Runtime. Remoting.Proxies.RealProxy.HandleReturnMessage (iMessage를 reqMsg, iMessage를 retMsg) VID System.Runtime.Remoting.Proxies.RealProxy.PrivateInvoke (MessageData & msgData, INT32 타입) VID IServiceManager.RetrieveData()의 VID ServiceManagerClient.RetrieveData()
예외 전체를 게시 할 수 있습니까? –
매핑 파일을 포함 리소스로 설정 했습니까? –
@MrMush 이제 했어요. 편집 한 질문을보고 싶습니까? – Mnemonics