This project is read-only.

Insert in table using Orchard NHibernate Issue

Topics: Writing modules
Jan 30, 2016 at 7:55 AM
I'm working on a module in orchardCMS and I am trying to save object in database but when I invoke the method create it throws exception saying "NHibernate Property Value exception" not-null property references a null or transient value LinksHandling.Models.Links_DM.ContentItemRecord

In my db table all columns are nullable but ID column is not nullable and Id Column is Identity so in my object I have values in all attributes and id is set to 0. When I go to save this object as below it donot work. However I have made such a function earlier and it was working as well.

public bool createLink(Links_DM linkModel)

        var link = _linksRepository.Table.FirstOrDefault(p => p.LinkUrl == linkModel.LinkUrl);
        if (link == null)
            try {                                        
                return true;
            catch (Exception) 
                return false;
        return false;
I'm banging my head to figure the issue but could not reach to a solution yet.

here is my Migration.cs

            table => table
                .Column<int>("Id", column => column.PrimaryKey().Identity())
Please help me figure out The issue. Thanks, Sohaib
Feb 5, 2016 at 11:27 PM
Could you share the code for the Links_DM class?
Feb 5, 2016 at 11:28 PM
Also, could you show the code that instantiates the linkModel argument?