简体   繁体   中英

How to develop a JayData query based on OData provider with any-all support for list{String}

Consider the following JayData entities:

           var Todo = $data.Entity.extend("Todo", {
                Id: { type: "int", key: true, computed: true },
                Task: { type: String, required: true, maxLength: 200 },
                DueDate: { type: Date },
                Completed: { type: Boolean },
                Person: { type: "Person", required: true, inverseProperty: "Todos" }
            });

            var Person = $data.Entity.extend("Person", {
                Id: { type: "int", key: true, computed: true },
                Name: { type: String, required: true, maxLength: 200 },
                Todos: { type: $data.Array, elementType: Todo, inverseProperty: "Person" },
                OtherNames : { type : $data.Array, elementType: String }
            });

Each person has many Todo items.

And now I can load people who have at least one completed todo. (With JayData 1.3.4 & Web API & OData 5.6 and IIS 7 on Windows Server 2008 R2).

Take a look at the sample which is working fine: http://jsfiddle.net/ysmoradi/P59jz/5/

But I want to run another query which is a little more different than this one.

I'd like to load people who have special names in their List{String} of OtherNames

Sample of OData query of my problem that works fine:

People?$filter=OtherNames/any(name:name eq 'AAA' or name eq 'BBB');

How can I accomplish this OData query within JayData in any possible way ?

Thanks

You can express the OData any query operator with the some() JayData operator. The documentation of the every() and some() operators of JayData can be found here - Using some() and every() with JayData OData provider

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM