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 7567669
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 30, 20262026-05-30T14:43:20+00:00 2026-05-30T14:43:20+00:00

One of my entity classes would be possible to store in a sql server

  • 0

One of my entity classes would be possible to store in a sql server
database as a BIGINT. My question is: How do I get a Entity Framework
context to know how to store and retrieve instances of my entity class?

More detail. I’m using Noda Time, which can represent a (much) wider range of
dates than can SQL or .NET datetime (AND it’s a dessert topping). My Entity Class, Happening, is a wrapper around NodaTime’s
Instant class. I can set a Happening from a long, and get a long from
a happening with methods like .SetFromLong(long instant) and .ToLong().

Currently I have my model working, saving classes that contain
properties of the dot net DateTime type. If instead I want to use properties
of my custom type “Happening”, how do I tell Entity Framework how to save those?

If I’m reading this article about Modeling and Mapping am I on the
right track or missing something simpler?

http://msdn.microsoft.com/en-us/library/bb896343.aspx

I’m using entity framework 4.

  • 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-30T14:43:22+00:00Added an answer on May 30, 2026 at 2:43 pm

    What i recommend doing is adding 2 properties on your entity a NodaTime and a long, and exclude your NodaTime property using [NotMapped] in your EF model, then in your getter/setter update the long.

    ie

    public class MyEntity{
       public long TimeAsLong{get;set;}
       [NotMapped]
       public Happening {
          get{
            return new Happening().SetFromLong(TimeAsLong);
          }
          set {
             TimeAsLong = value.ToLong();
          }
       }
    }
    

    The effect of this will be that the long is stored in the db but you can access it on the class via NodaTime

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

Sidebar

Related Questions

Is it possible to refresh only one entity in entity framework designer? Every time
it's possible to have one entity object (class, e.g. User) for more entity models
How would one structure a table for an entity that can have a one
What does one loose by creating POCO using T4 templates in entity framework 4.0?
I have two entity classes: public class Invoice { public int ID { get;
I'm using Entity Framework 4.1 and trying to create a one-to-many relationship. In my
I have a project with ASP.NET MVC, using Entity Framework to get data from
Hi every one I have these classe @Entity @Table(name = login, uniqueConstraints={@UniqueConstraint(columnNames={username_fk})}) public class
I have a field aliases of type java.util.Set in one Entity . This Set
I have a collection of custom entity objects one property of which is an

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.