下面的代码在NHibernate中实际做了什么:
<mapping assembly="Sample" /> //in the config file
Run Code Online (Sandbox Code Playgroud)
要么
Configuration config = new Configuration();
config.AddAssembly("Sample"); //in the code file
Run Code Online (Sandbox Code Playgroud)
此"Sample"对应于.NET中Project的主命名空间,还是它可以是我们应用程序中任何Business Object的名称?
我在客户端UI(Silverlight 3.0)和数据层之间使用WCF服务.我们正在使用NHibernate进行数据库访问.所以请告诉我,我的以下理解是否正确:
也有人可以告诉我,我们如何将对象从WCF传递到UI(Silverlight 3.0)层,反之亦然.我读过我们使用DTO.但是DTO如何运作?它们是否与WCF中的"数据合同"相对应?如果没有,那么是否在WCF(服务器)端和客户端代码上声明了DTO?
我试图在WCF中使用这个简单的代码:
客户端:
ServiceContractClient proxy = new ServiceContractClient();
using (OperationContextScope scope = new OperationContextScope((IContextChannel)proxy.InnerChannel))
{
MessageHeaders messageHeadersElement = OperationContext.Current.OutgoingMessageHeaders;
messageHeadersElement.Add(MessageHeader.CreateHeader("username", String.Empty, System.Security.Principal.WindowsIdentity.GetCurrent().Name));
}
var res = proxy.CallWCFMethod();
Run Code Online (Sandbox Code Playgroud)
服务器端:
CallWCFMethod实现了另一个方法GetInfo().GetInfo()的代码是:
MessageHeaders messageHeadersElement = OperationContext.Current.IncomingMessageHeaders;
int AdidIndex = messageHeadersElement.FindHeader("username", string.Empty);
string ticket = messageHeadersElement.GetHeader<string>("username", string.Empty);
Run Code Online (Sandbox Code Playgroud)
但是这段代码永远找不到我在客户端添加的Header"用户名".有人能指出我在这里做错了什么吗?
我想我的映射Dictionary<int, string>到一个List<Customer>地方Customer有两个属性Id和Name.现在我想迭代地将字典的整数映射Key到List<Customer>[i].Key属性和Value字典List<Customer>[i].Name.
需要帮助.