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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 31, 20262026-05-31T20:18:01+00:00 2026-05-31T20:18:01+00:00

I currently have the following in one solution: Core Project (data access, biz logic,

  • 0

I currently have the following in one solution:

  1. Core Project (data access, biz logic, petapoco for data access, the plumbing, etc)
  2. Models Project (just models and petapoco decorations for just attributes)
  3. Web Project (MVC project for presentation

I want to have my Models and Core seperate, but I can’t have PetaPoco.cs in both places. How would I seperate it and still be able to decorate the POCOs in my Models project with PetaPoco attributes?

I don’t want the Models project to have a dependency on the Core project.

I did create this seperate class to be only in the Models project so I could decorate the POCOs, but the attributes are not being picked up properly by the Core PetaPoco project. It relies on PocoData too much.

Suggestions?

// Poco's marked [Explicit] require all column properties to be marked
[AttributeUsage(AttributeTargets.Class)]
public class ExplicitColumnsAttribute : Attribute
{
}
// For non-explicit pocos, causes a property to be ignored
[AttributeUsage(AttributeTargets.Property)]
public class IgnoreAttribute : Attribute
{
}

// For explicit pocos, marks property as a column and optionally supplies column name
[AttributeUsage(AttributeTargets.Property)]
public class ColumnAttribute : Attribute
{
    public ColumnAttribute() { }
    public ColumnAttribute(string name) { Name = name; }
    public string Name { get; set; }
}

// For explicit pocos, marks property as a result column and optionally supplies column name
[AttributeUsage(AttributeTargets.Property)]
public class ResultColumnAttribute : ColumnAttribute
{
    public ResultColumnAttribute() { }
    public ResultColumnAttribute(string name) : base(name) { }
}

// Specify the table name of a poco
[AttributeUsage(AttributeTargets.Class)]
public class TableNameAttribute : Attribute
{
    public TableNameAttribute(string tableName)
    {
        Value = tableName;
    }
    public string Value { get; private set; }
}

// Specific the primary key of a poco class (and optional sequence name for Oracle)
[AttributeUsage(AttributeTargets.Class)]
public class PrimaryKeyAttribute : Attribute
{
    public PrimaryKeyAttribute(string primaryKey)
    {
        Value = primaryKey;
        autoIncrement = true;
    }

    public string Value { get; private set; }
    public string sequenceName { get; set; }
    public bool autoIncrement { get; set; }
}

[AttributeUsage(AttributeTargets.Property)]
public class AutoJoinAttribute : Attribute
{
    public AutoJoinAttribute() { }
}
  • 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-31T20:18:02+00:00Added an answer on May 31, 2026 at 8:18 pm

    I think one obvious solution, though, I’m not sure it’s that much better, is to move PetaPoco to its own project and then reference that in both your Core and Models projects. Your models still have an external dependency, though, just not the whole Core assembly.

    One other alternative would be to have your decorated models in your Core project for internal use, and then have a set of undecorated classes in your Models assembly. You could use an auto-mapping component to map between the two easily. So basically you would use PetaPoco to fetch data into your internal model, and then map that over to your ‘external’ model which is just bare classes with no dependencies.

    Of course, that sounds like a lot of extra work. I guess it all hinges on how critical it is that your Model assembly have no other dependencies.

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

Sidebar

Related Questions

Currently I have database with the following associations: One Client to Many Intakes One
I currently have the following objects persisting successfully: Person first name, etc. Exams title,
Currently, I have the following structure for my project Foo : foo-parent +- pom.xml
I currently have a solution with a couple of projects and one of them
I'm looking for an elegant solution to the following problem: I currently have a
Currently I have a the following way of retrieving data from my DB: $school->get('studentCount');
We have a Visual Studio 2008 solution with 58 projects. One project targets the
I currently have the following CSS for my 4 columns which might grow to
I currently have the following row in my table: course_data: user_id days <-- This
I currently have the following MySQL statement to replace the HTML entity for 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.