Problems in using for project development

Source: Internet
Author: User
I recently used base4.nethttp: // to develop an Account Management System, which defines a class of notecategory.

Public   Class Notecategory


PublicItemcollection parents;//Target is source


The general XML schema is as follows:

<! -- Define form template type entity -->

< Typedef Fullname = "DGSoft. notecategory" Basename = "Maxtiviti. Storage. itembase" >

< Propertydef Name = "Title" Type = "String" Length = "100" Nullable = "False"   />

< Relationshipdef Name = "Members" Type = "Maxtiviti. Storage. itembase" Relationshipname = "Notecategorymembers" Direction = "Linkissource"   />

< Propertydef Name = "Copyright" Type = "String" Length = "200" Nullable = "True"   />

< Propertydef Name = "Description" Type = "String" Length = "1000" Nullable = "True"   />

< Relationshipdef Name = "Parents" Type = "DGSoft. notecategory" Relationshipname = "Notecategorymembers" Direction = "Linkistarget"   />

</ Typedef >

Now, you need to query all typeof (notecategory) objects to meet the condition of parents. Count = 0;

However, objectpath "parents. count = 0 "or" parents [count] = 0 "cannot be queried, and an exception is thrown. Therefore, the forums of is used to ask. The result is as follows:

Ask (me ):

I defined a class "notecategory" that contains a attribute "parents"

The attribute is a collection

How to query the object typeof (notecategory) that parents. Count = 0 ?????

How to constuct the objectpath ??


Thanks very much !!!!

Answer: (Alex James)

I don't support embedding a count filter on a relationship in objectpath yet... Sorry.

Although what you are asking for shoshould be added... I will have a think about how in the next few days.

The problem is that I collapse callto object. relationship so that you are querying the related object not the actual relationship table.

What needs to be done is to add additional hardcoded filters to the object. relationship so that you can do the sort of things you are asking .... I will probably add support for this before beta3.

While you can't do it with object path you can do it...

If you use an objectcommand and write the SQL yourself.

Execute the objectcommand so it returns a reader (executereader) and Contruct an objectdatareader around the returned Reader so you can read your notecategory objects.

It depends how you defined your relationshipdef, if parent is defined with linkissource and a relationshipname = parent

This wowould return you all notecategories without parents:

Select * from [notecategory] Where id not in (select distinct (source) from [maxtiviti. Storage. Relationship] Where name = 'parent ')

When I get a chance I will post you a snippet on how to use this code with a objectcommand...

Haha, I really hope Alex can get out of beta3 soon. If I want to use the following solutions, there will be a lot of performance problems:

Public Itemcollection getallrootcategory ()


Itemcollection result =   New Itemcollection ();

Itemcollection IC = Storagecontext. Find ( Typeof (Notecategory ), Null );

Foreach (Notecategory NC In Ic)


If(Nc. Parents. Count= 0)

Result. Add (NC );


Return Result;


although we can use the method proposed by Alex to write SQL statements, isn't that quite elegant?

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.