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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 2, 20262026-06-02T14:33:50+00:00 2026-06-02T14:33:50+00:00

I have two POCO objects as such: ///<summary> ///Auto-generated concrete POCO for persistance use

  • 0

I have two POCO objects as such:

///<summary>
///Auto-generated concrete POCO for persistance use <strong>Log</strong>
///</summary>
public class Log : ILogExtended
{
    #region Primitive Properties

    ///<summary>
    /// The log entry ID
    ///</summary>
    public virtual int LogId { get; set; }

    ///<summary>
    /// The timestamp of the log entry (UTC)
    ///</summary>
    public virtual DateTime TimeStamp { get; set; }

    ///<summary>
    /// The thread ID that generated the log entry
    ///</summary>
    public virtual string Thread { get; set; }

    ///<summary>
    /// The severity of the log entry
    ///</summary>
    public virtual string Severity { get; set; }

    ///<summary>
    /// The source module of the log entry
    ///</summary>
    public virtual string Source { get; set; }

    ///<summary>
    /// The log entry message
    ///</summary>
    public virtual string Message { get; set; }

    ///<summary>
    /// The associated exception text associated with the log entry
    ///</summary>
    public virtual string Exception { get; set; }
    #endregion

    #region Navigation Properties

    ///<summary>
    /// The user associated with the log entry
    ///</summary>
    public virtual UserProfile UserProfile { get; set; }
    #endregion

    #region Navigation Collections
    #endregion
} 

and

///<summary>
///Auto-generated concrete POCO for persistance use <strong>UserProfile</strong>
///</summary>
public class UserProfile : IUserProfileExtended
{
    #region Primitive Properties

    ///<summary>
    /// The unique ID of the profile
    ///</summary>
    public virtual int UserID { get; set; }

    ///<summary>
    /// The given name of the profile
    ///</summary>
    public virtual string GivenName { get; set; }

    ///<summary>
    /// The middle name of the profile
    ///</summary>
    public virtual string MiddleName { get; set; }

    ///<summary>
    /// The family name of the profile
    ///</summary>
    public virtual string FamilyName { get; set; }

    ///<summary>
    /// The user name of the profile
    ///</summary>
    public virtual string UserName { get; set; }

    ///<summary>
    /// The nickname of the profile
    ///</summary>
    public virtual string NickName { get; set; }

    ///<summary>
    /// The first address line of the profile
    ///</summary>
    public virtual string Address1 { get; set; }

    ///<summary>
    /// The second address line of the profile
    ///</summary>
    public virtual string Address2 { get; set; }

    ///<summary>
    /// The mailing address city of the profile
    ///</summary>
    public virtual string City { get; set; }

    ///<summary>
    /// The mailing address state of the profile
    ///</summary>
    public virtual string State { get; set; }

    ///<summary>
    /// The mailing address zip code of the profile
    ///</summary>
    public virtual string ZipCode { get; set; }

    ///<summary>
    /// The user's self description
    ///</summary>
    public virtual string Bio { get; set; }

    ///<summary>
    /// The user's birth date.
    ///</summary>
    public virtual Nullable<DateTime> BirthDate { get; set; }

    ///<summary>
    /// The user's photo URL
    ///</summary>
    public virtual string LinkToAvatar { get; set; }

    ///<summary>
    /// The user's website URL
    ///</summary>
    public virtual string LinkToWebpage { get; set; }
    #endregion

    #region Navigation Properties
    #endregion

    #region Navigation Collections

    ///<summary>
    /// The log entries of the user's actions
    ///</summary>
    public virtual IList<Log> ActivityLogs { get; set; }
    #endregion
} 

These objects are mapped in the database as follows:

<?xml version="1.0" encoding="utf-8" ?>
<hibernate-mapping xmlns="urn:nhibernate-mapping-2.2"
                    assembly="C3.DataModel.Generated"
                    namespace="C3.DataModel">
    <class name="Log" table="Logs">
        <id name="LogId">
            <generator class="identity" />
        </id>
        <property name="TimeStamp" column="TimeStamp" index="ixLogTimeStamp" not-null="true" />
        <property name="Thread" length="255" column="Thread" not-null="true" />
        <property name="Severity" column="Severity" not-null="true" />
        <property name="Source" length="255" not-null="false" column="Source" />
        <property name="Message" length="4000" not-null="true" column="Message"/>
        <property name="Exception" length="4000" column="Exception"/>
        <many-to-one name="UserProfile" column="UserID" cascade="none" not-found="ignore"/>
    </class>
</hibernate-mapping>

and

<?xml version="1.0" encoding="utf-8" ?>
<hibernate-mapping xmlns="urn:nhibernate-mapping-2.2"
                    assembly="C3.DataModel.Generated"
                    namespace="C3.DataModel">
    <class name="UserProfile" table="UserProfiles">
        <id name="UserID">
            <generator class="assigned" />
        </id>
        <property name="GivenName" length="40" column="GivenName" />
        <property name="MiddleName" length="40" column="MiddleName" not-null="false" />
        <property name="FamilyName" length="40" column="FamilyName" />
        <property name="UserName" length="250" index="ixUserName" unique="true" />
        <property name="NickName" length="40" column="NickName" />
        <property name="Address1" length="50" column="Address1" />
        <property name="Address2" length="50" column="Address2" />
        <property name="City" length="50" column="City" />
        <property name="State" length="2" column="State" />
        <property name="ZipCode" length="10" column="ZipCode" />
        <property name="Bio" length="2000" column="Bio" not-null="false" />
        <property name="BirthDate" not-null="false" column="BirthDate" />
        <property name="LinkToAvatar" length="250" column="LinkToAvatar" not-null="false" />
        <property name="LinkToWebpage" length="250" column="LinkToWebPage" not-null="false" />
    </class>
</hibernate-mapping>

I am trying to build a Log Searcher function as such:

    /// <summary>
    /// Searches the logs for matching records
    /// </summary>
    /// <param name="fromUTC">Start point timestamp of the search</param>
    /// <param name="toUTC">End point timestamp of the search</param>
    /// <param name="ofSeverity">Severity level of the log entry</param>
    /// <param name="orHigher">Retrieve more severe log entries as well that match</param>
    /// <param name="sourceStartsWith">The source field starts with these characters</param>
    /// <param name="usernameStartsWith">The username field starts with these characters</param>
    /// <param name="maxRecords">The maximum nuber of records to return</param>
    /// <returns>A list of Log objects with attached UserProfile objects</returns>
    public IEnumerable<Log> SearchLogs(
        DateTime fromUTC, 
        DateTime toUTC, 
        string ofSeverity, 
        bool orHigher, 
        string sourceStartsWith, 
        string usernameStartsWith, 
        int maxRecords)
    {
        var result = _Session
            (SOMETHING goes here)
    }

As a n00b at NHibernate, this sort of multifaceted query has got me scratching my head, and I’d appreciate some assistance. If you can make it clear how I would modify the statements for other similar queries, I’d be hugely grateful.

One note: the Severity will be an IEnumerable<string>, of either one value or more if the orHigher parameter is set.

Thanks for your attention.

  • 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-02T14:33:51+00:00Added an answer on June 2, 2026 at 2:33 pm

    Here’s what I ended up with, feel free to tell me if I’m doing something incorrectly or inefficiently:

        /// <summary>
        /// Searches the logs for matching records
        /// </summary>
        /// <param name="fromUTC">Start point timestamp of the search</param>
        /// <param name="toUTC">End point timestamp of the search</param>
        /// <param name="ofSeverity">Severity level of the log entry</param>
        /// <param name="orHigher">Retrieve more severe log entries as well that match</param>
        /// <param name="sourceStartsWith">The source field starts with these characters</param>
        /// <param name="usernameStartsWith">The username field starts with these characters</param>
        /// <param name="maxRecords">The maximum number of records to return</param>
        /// <returns>A list of Log objects with attached UserProfile objects</returns>
        public IEnumerable<Log> SearchLogs(
            DateTime fromUTC,
            DateTime toUTC,
            string ofSeverity,
            bool orHigher,
            string sourceStartsWith,
            string usernameStartsWith,
            int maxRecords)
        {
            ofSeverity = ofSeverity ?? "INFO";
    
            var query = DetachedCriteria.For<Log>()
                .SetFetchMode("UserProfile", NHibernate.FetchMode.Eager)
                .Add(Restrictions.In("Severity", (orHigher ?
                    Translator.SeverityOrHigher(ofSeverity) : Translator.Severity(ofSeverity)).ToArray()))
                .Add(Restrictions.Between("TimeStamp", fromUTC, toUTC))
                .AddOrder(Order.Desc("TimeStamp"))
                .SetMaxResults(maxRecords);
    
            if (!string.IsNullOrEmpty(usernameStartsWith))
            {
                query.CreateCriteria("UserProfile")
                    .Add(Restrictions.InsensitiveLike("UserName",
                    usernameStartsWith, MatchMode.Start));
            }
    
            if (!string.IsNullOrEmpty(sourceStartsWith))
            {
                query
                    .Add(Restrictions.InsensitiveLike("Source", sourceStartsWith, MatchMode.Start));
            }
    
            return query.GetExecutableCriteria(_Session).List<Log>();
    
        }
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have two POCO objects: public class Product { public int ProductID { get;
I have a two classes: public class Question { public IList<Answer> Answers { get;
Say I have the following POCO classes: public class AuditableModel { public int ID
I have two classes generated by LINQ2SQL both from the same table so they
I have two stored procedures I wish to use in my stored procedure, but
I have a database table and a corresponding entity class (POCO with change tracking
I have two simple POCO classes; I'm trying to get the MyY property below
I have created a model POCO class called Recipe ; a corresponding RecipeRepository persists
I have two POCO classes a User and an Address. Address is a complex
I have a simple POCO class that contains the student's scores. For example: Math

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.