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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 18, 20262026-06-18T17:35:05+00:00 2026-06-18T17:35:05+00:00

I have DB view ALL_ATM_DEV_SATTRIB_VALS DEVICE_ID ATTRIB_ID INT_VALUE STRING_VALUE DATE_VALUE 1 13 null 10.0.3.50

  • 0

I have DB view ALL_ATM_DEV_SATTRIB_VALS

DEVICE_ID   ATTRIB_ID    INT_VALUE    STRING_VALUE    DATE_VALUE

1           13           null         10.0.3.50       null
1           14           0            null            null
1           15           null         null            null

2           13           null         10.0.3.51       null
2           14           2            null            null
2           15           null         null            null

Entity objects

public class AttributeValue: IAttributeValue
{
    public virtual string StringValue { get; set; }
    public virtual DateTime? DateValue { get; set; }
    public virtual int? IntValue { get; set; }
}

public class Device : IDevice
{
    public virtual long Id { get; set; }        

    public virtual IDictionary<long, IAttributeValue> Values { get; set; }
}

Mapping file(hbm)

<class name="Device" table="DEVICES" lazy="true" >

<id name="Id" column="ID" ></id>

<map name="Values " batch-size="10" table="ALL_ATM_DEV_SATTRIB_VALS" lazy="true">
  <key column="DEVICE_ID" />
  <index column="ATTRIB_ID" type="System.Int64" />

  <composite-element class="AttributeValue">
    <property name="StringValue"  column="STRING_VALUE" />
    <property name="DateValue"  column="DATE_VALUE" />
    <property name="IntValue"  column="INT_VALUE" />
  </composite-element>
</map>

</class>

Selecting dictionaries values work correctly, but when i tried use it in Linq expressions

List<IDevice> a = dc.Get<IDevice>()
                    .Where(x=>x.Values[13].StringValue
                                          .ToLower().Contains("10.0.3"))
                    .ToList();

nhibernate throw exception

System.InvalidOperationException: Cannot create element join for a collection of non-entities!

In the object Device I need to have IDictionary. Key is ATTRIB_ID(long), Value is AttributeValue

  • 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-18T17:35:07+00:00Added an answer on June 18, 2026 at 5:35 pm

    Nhibernate can’t create a sql-query use IDictionary<long, IAttributeValue> because IAttributeValue don’t map in hbm as entity.

    But i solved this problem.

    I replaced the mapping of one IDictionary to three simpler :

     <map name="StringValues" table="ALL_ATM_DEV_SATTRIB_VALS" lazy="true" fetch="select">
      <key column="DEVICE_ID" />
      <index column="ATTRIB_ID" type="System.Int64" />
      <element column="STRING_VALUE" type="System.String"/>
    </map>
    <map name="DateValues" table="ALL_ATM_DEV_SATTRIB_VALS" lazy="true" fetch="select">
      <key column="DEVICE_ID" />
      <index column="ATTRIB_ID" type="System.Int64" />
      <element column="DATE_VALUE" type="System.DateTime"/>
    </map>
    <map name="IntValues" table="ALL_ATM_DEV_SATTRIB_VALS" lazy="true" fetch="select">
      <key column="DEVICE_ID" />
      <index column="ATTRIB_ID" type="System.Int64" />
      <element column="INT_VALUE" type="System.Int64"/>
    </map>
    

    I use this maps only for create result sql-query, thats why lazy=true is present, and
    never access to them in the entity IDevice

    Data of this maps selected an another sql-query at once, because lazy initialization would cause n+1 sql-queries on DB.

    Linq query in my question transformed in :

    List<IDevice> a = dc.Get<IDevice>()
                    .Where(x=>x.StringValues[13].ToLower().Contains("10.0.3"))
                    .ToList();
    

    In IDevice entity defined three maps :

        public virtual IDictionary<long, long> IntValues { get; set; }
        public virtual IDictionary<long, string> StringValues { get; set; }
        public virtual IDictionary<long, DateTime> DateValues { get; set; }
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have a view which displays a model eg: public class MyModel() { public
I have a View User : public class User { public int id {
Hi all I have a view with these controls on it <input type=text class=radius2
I have the following: public Class Vacancy{ public int VacancyID {get;set;} public List<Application> Applications
I have a signed public key. I wanted to view all the signatures in
I have html like this <h2 class=Comprehensive Leadership>Comprehensive Leadership</h2><a href=/topic/comprehensiveleadership>View all Comprehensive Leadership Programs
I have 4 info, tat i get frm database. I want to view all
I believe I have disabled the view state on all controls as well as
I have 5 view which have deferent json data , in all my 5
I have a Pages table that stores all my view urls and this table

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.