English 中文(简体)
如何使用流利物删除表格的内容?
原标题:How can i delete the content of the table using fluentnhibernate?

我在地图上使用流体核,具体如下:

public class ContentTagMap: ClassMap<Employee>
{
    public EmployeeMap()
    {
        Id(t => t.Id);
        Map(t => t.Name);
        HasManyToMany(t => t.Company);
    }
}

public class CompanyMap: ClassMap<Company>
{
    public HelpMap()
    {
        Id(h => h.Id);
        Map(h => h.CompanyName).Length(6000);
        Map(h => h.address).Length(6000);
        HasManyToMany(h => h.Employee);
    }
}

这些绘图产品 Employee Table,Company table and Employee ToCompany

www.un.org/spanish/ecosoc Employee Table

Id    Name
1     John
2     MAX

Company Table

Id    CompanyName   address
1      HTC           ABC
2      HTC2          India

<>Employee ToCompany>>

Employee_Id     Company_Id
1               1
2               1

我怎么能用Id 1删除该雇员?

最佳回答

除非我误解,否则你应问:

How can i delete the content of the table using NHibernate?

液化NHibernate只是帮助测绘贵实体的工具。 <>NHibernate 是你用来生成、阅读、更新和删除数据。 无论如何:

9.5. 删除持久性物体

ISession.Delete() will remove an object s state from the database. Of course, your application might still hold a reference to it. So it s best to think of Delete() as making a persistent instance transient.

http://www.nhforge.org/doc/nh/en/index.html# editedingdata-deleting”rel=“nofollow noreferer”>NHibernate Documentation

You probably want to also define a Cascading style on your many to many relationship (HasManyToMany) in your mapping.

If you use Cascade.SaveUpdate in your many to many whenever you delete an entity on one side of the relationship it will delete that entity and any relationships. If you remove the association (ex. if you removed an Employee from a Company) it will only delete the relationship (EmployeeToCompany). This is what I ve typically found to work in the case of many to many relationships.

看看这一条,需要了解更多关于图谱和在流感国家使用许多到许多关系的细节。

how to keep many to many relationships in sync with nhibernate?

问题回答

暂无回答




相关问题
nHibernate one-to-many inserts but doesnt update

Instead of getting into code, I have a simple question. Default behavior for a simple one-to-many is that it inserts the child record then updates the foreign key column with the parent key. Has ...

How Do I copy an existing nhibernate object as a new object?

I a persisted NHibernate object that I would like to repersist as a new entity. How do I get NHibernate to save this object as if it was a new? I am thinking I might create a session interceptor to ...

join across databases with nhibernate

I am trying to join two tables that reside in two different databases. Every time, I try to join I get the following error: An association from the table xxx refers to an unmapped class. If the ...

WPF - MVVM - NHibernate Validation

Im facing a bit of an issue when trying to validate a decimal property on domain object which is bound to a textbox on the view through the viewmodel. I am using NHibernate to decorate my property on ...

NHibernate Search in a List using ICriteria

I have my class X : public class ClassX { public virtual IList<ClassY> ListY { get; set; } ... } My ClassX mapping (using Fluent) ... HasMany<ClassX>(x => x.ListY ) ....

热门标签