Saturday, November 09, 2013

NotMapped attribute for PetaPoco or Ignore Column while Insert/Update in Petapoco

NotMapped Property for PetaPoco or Ignore Column while Insert/Update in Petapoco

[NotMapped]   ==>  [ResultColumn]

[NotMapped] equivalent of entity framework in Petapoco is [ResultColumn]

For more information

Example:  If you have contact form model where you want user to enter captcha, but you don't want this captcha to be store in db, so In order to ignore captcha column while inserting values in database you can mark the column as [NotMapped] in entity framework and if you are using Petapoco you can use attribute [ResultColumn]

[TableName("contact")]
[ExplicitColumns]
public class contact
{
    [Column] 
    public string FullName { get; set; }
    
    [Column] 
    public string Feedback { get; set; }
    
    [ResultColumn] 
    public string Captcha { get; set; }
}

No comments:

Most Recent Post

Subscribe Blog via Email

Enter your email address:



Disclaimers:We have tried hard to provide accurate information, as a user, you agree that you bear sole responsibility for your own decisions to use any programs, documents, source code, tips, articles or any other information provided on this Blog.
Page copy protected against web site content infringement by Copyscape