我有以下代码:
public void ProcessRequest (HttpContext context)
{
context.Response.ContentType = "text/rtf; charset=UTF-8";
context.Response.Charset = "UTF-8";
context.Response.ContentEncoding = System.Text.Encoding.UTF8;
context.Response.AddHeader("Content-disposition", "attachment;filename=lista_obecnosci.csv");
context.Response.Write("??????ó????????Ó?");
}
Run Code Online (Sandbox Code Playgroud)
当我尝试打开生成的csv文件时,我得到以下行为:
我想在我的字符串前写下那些特殊的编码信息字符,即
context.Response.Write((char)0xef);
context.Response.Write((char)0xbb);
context.Response.Write((char)0xbf);
Run Code Online (Sandbox Code Playgroud)
但那不会有任何好处.响应流将其视为普通数据并将其转换为不同的数据.
我很感激这方面的帮助.
我有以下映射定义:
<class name="Role" table="Role" optimistic-lock="version" >
<id name="Id" type="Int32" unsaved-value="0" >
<generator class="native" />
</id>
<property name="RoleName" type="String(40)" not-null="true" />
<bag name="UsersInRole" generic="true" lazy="true" cascade="all" table="UserRoles" >
<key column="RoleId" />
<many-to-many column="UserId" class="SystemUser, Domain"/>
</bag>
Run Code Online (Sandbox Code Playgroud)
和
<id name="Id" type="Int32" unsaved-value="0" >
<generator class="native" />
</id>
<property name="UserName" type="String(40)" not-null="true" unique="true" />
Run Code Online (Sandbox Code Playgroud)
此映射生成映射表UserRoles,它有两列 - RoleId和UserId.
但是,我想为该关系添加额外的属性 - 即一些枚举值定义关系的状态以及有效的开始和结束日期.
是否可以在nhibernate中执行或者我是否需要在此处添加其他类并将关系m-to-m更改为2个关系[user] 1-to-m [user_role] m-to-1 [role]?
我有以下型号:
<class name="Person" table="Person" optimistic-lock="version">
<id name="Id" type="Int32" unsaved-value="0">
<generator class="native" />
</id>
<!-- plus some properties here -->
</class>
<class name="Event" table="Event" optimistic-lock="version">
<id name="Id" type="Int32" unsaved-value="0">
<generator class="native" />
</id>
<!-- plus some properties here -->
</class>
<class name="PersonEventRegistration" table="PersonEventRegistration" optimistic-lock="version">
<id name="Id" type="Int32" unsaved-value="0">
<generator class="native" />
</id>
<property name="IsComplete" type="Boolean" not-null="true" />
<property name="RegistrationDate" type="DateTime" not-null="true" />
<many-to-one name="Person" class="Person" column="PersonId" foreign-key="FK_PersonEvent_PersonId" cascade="all-delete-orphan" />
<many-to-one name="Event" class="Event" column="EventId" foreign-key="FK_PersonEvent_EventId" cascade="all-delete-orphan" />
</class>
Run Code Online (Sandbox Code Playgroud)
在Person和Event中都没有指向PersonEventRegistration的属性.
当我尝试从PersonEventRegistration中删除条目时,出现以下错误:
"deleted object …
Run Code Online (Sandbox Code Playgroud)