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

  • Home
  • SEARCH
  • 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 8853933
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 14, 20262026-06-14T13:46:03+00:00 2026-06-14T13:46:03+00:00

I have following scenario… Massive Micro-ORM .NET framework 4.0 SQL Server 2008R2 Model: public

  • 0

I have following scenario…

  • Massive Micro-ORM
  • .NET framework 4.0
  • SQL Server 2008R2

Model:

public class sUser : DynamicModel
{
    public sUser() : base(Model.strConnection, "Users", "UserId") { }
}

public class Test
    {
        public void UpdateUser(string user)
        {
            dynamic User = GetUser(user);

            //Dynamically generated User object has many columns
            // I Update following fields...
            User.Address1 = "123 Main Street";
            User.Address2 = "Suite# 456";
            User.CityName = "Princeton";
            User.State = "NJ";
            User.Zipcode = "08540";
            //And update some more fields in Users object

           //I could do this...
            //var upd = new { Address1 = "123 Main Street", Address2 = "Suite# 456", ...};
            //User.Update(upd, User.UserID);

            //But would like to pass entire object, so I do not have to form all updated name/value in the update statement
            User.Update(User, User.UserID);

            //But Users table has a column with IDENTITY SEED,
            //And if I pass entire object for update it errors out
            //Cannot update identity column 'RefNo'
        }

        public dynamic GetUser(string userName)
        { 
            dynamic table = new sUser();
            var objUser = table.First(UserName: userName);

            return objUser;
        }
    }

Users table has a column RefNo with IDENTITY SEED=1, and when I update entire User object, it errors out Cannot update identity column ‘RefNo’. I would like to pass entire object for update rather than forming long update statement.

How can I handle this?

Thanks.

  • 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-06-14T13:46:04+00:00Added an answer on June 14, 2026 at 1:46 pm

    Modify Massive.cs
    – Add following under DynamicModel class

    private string IdentityColumn { get; set; }
    
     private string GetIdentityColumn()
     {
        return (string)Scalar("SELECT C.name AS IdentityColumn FROM sys.columns C Inner Join sys.tables T ON T.object_id = C.object_id WHERE C.is_identity = 1 And T.name = '" + TableName + "'");
     }
    

    And under CreateUpdateCommand method add following…

    IdentityColumn = GetIdentityColumn();
    

    And under foreach loop modify if statement to following…

    if (!item.Key.Equals(PrimaryKeyField, StringComparison.OrdinalIgnoreCase) && item.Value != null && item.Key != IdentityColumn)
    

    Above change into Massive library would allow us to update model with identity column. Limitation: Works for Table with one IDENTITY column.

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

Sidebar

Related Questions

I am trying to understand isolation/locks in SQL Server. I have following scenario in
I have the following scenario :- template <typename T> class Base { public: virtual
I have the following scenario. I have created an ASP.NET web application (framework 3.5)
I have the following scenario: class my_base { ... } class my_derived : public
I have the following scenario: in my models.py class FooBar(models.Model): description = models.CharField(max_length=20) in
I have this following scenario namespace A { //... class A { public: static
I have the following scenario public class Foo { public Bar FooBar { get;
I have the following scenario, class foo { ... private: char *_test; }; void
I have following Scenario: PHP(Server, Writer) ----> MySQL Database <------ PHP(Client, Reader/ Writer); PHPS
I have the following scenario in my code (C# .NET 4): I have a

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.