Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 5961555
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 22, 20262026-05-22T18:58:52+00:00 2026-05-22T18:58:52+00:00

I have two classes Office and FileDataObject defined as: public class Office { public

  • 0

I have two classes Office and FileDataObject defined as:

public class Office
{
   public virtual string Name { get; set; }
   public virtual string Phone { get; set; }
   public virtual **FileDataObject** OfficePdf { get; set; }
}

public class FileDataObject
{
   public virtual int? Id { get; set; }
   public virtual ContentType ContentType {get;set;}
   public virtual string FilePath {get;set;}
}

with mappings defined as:

public class OfficeMap : ClassMap<Office>
{
   Map(x => x.Name).Not.Nullable();
   Map(x => x.Phone).Length(20);
   References<FileDataObject>(x => x.OfficePdf).Cascade.All().Column("OfficePdfId").Nullable().ForeignKey("FK_Office_FileDataObject");
}

public class FileDataObjectMap : ClassMap<FileDataObject>
{
   Id(x => x.Id).UnsavedValue(null).GeneratedBy.Native();
   Map(x => x.ContentType);
   Map(x => x.FilePath);
}

For a single office, I need just one OfficePdf (FileDataObject), but it MAY BE NULL when no pdf is uploaded for a particular office. (so a 0..1 relationship)

Schema for above two is being generated correctly with
Table:Office-Column:OfficePdfId ->mapping-> PK-Id of Table: FileDataObject.

Please note that I do not want Table: FileDataObject to have OfficeId column as FileDataObject is being used by some other entities as well.

Though FileDataObject is being saved correctly, the issue I am facing is –

When user updates an existing office pdf, I am confused whether to
first delete the existing FileDataObject and then create a new one or
Update the existing pdf will be a better choice.

Or is there any way FNH can take care of it?

Could you please guide.

Thank you!

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-22T18:58:53+00:00Added an answer on May 22, 2026 at 6:58 pm

    Unless you have some specific requirement that will be met by deleting and re-creating, it’s probably easiest to just update the existing one. You can make the decision to create or update in your Office class, since it’s the owner of the FileDataObject

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have two classes: class Player { public string Id { set; get; }
I have two classes public class A { public int BaseA {get;set;} } public
I have two classes public class PrepaidPackage { private String name; private String serviceClassID;
I have two classes public class News { public virtual int Id { get;
I have two classes as follows: public class Info { [XmlAttribute] public string language;
I have two classes: namespace Something { [Serializable] public class Spec { public string
I have two classes: class Object { public: Object(); virtual void update(); virtual void
I have two classes : import android.cla; public class CW { public static void
I have two classes: public class Singleton{ private Singleton(){...} private static class InstanceHolder{ private
I have two classes, one nested in the other. Public Class Operation Public Property

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.