开发者

Searching many-to-many relations with Vici CoolStorage

开发者_Python百科

For an application used for managing booktitles and such, I'm using CoolStorage as an ORM.

The database has a table named 'titles'. Each title can have n authors, stored in the 'authors' table. The two tables are connected through the linktable 'titles_authors', which is pure.

When I try to filter titles on authors, I get an exception:

Unable to cast object of type 'QueryExpression' to type 'System.String'

Does anyone know how to filter the titles by author?


Set this up in your Title Class:

[ManyToMany("titles_authors", Pure = true, ForeignLinkKey = "AuthorId", LocalLinkKey = "TitleId")]
public abstract CSList<Author> Authors{ get; set; }

And vice versa in the Authors class...

Then you can access by:

CSList titlesByAuthor = Title.List("Authour.Name = "Bob Thorn");

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜