简体   繁体   English

公共方法+ C#+流利的Nhibernate + asp.net

[英]public method + c# + fluent nhibernate + asp.net

I want to reduce the code duplication and have created a public method to get all the categories from the database (this is in my repository for the categoryclass). 我想减少代码重复,并创建了一个公共方法来从数据库中获取所有类别(这在我的类别库中)。 i want to do this public because i retieve the categoires in multiple pages. 我想公开进行此活动,因为我在多个页面中重新放置了类别。 When i populate a DDL i just want to call categories as the datasource. 当我填充DDL时,我只想将类别称为数据源。

It look something like: 它看起来像:

public IList<Category> categories()
{ //code to fetch the categories
  return categories;
}

But in my code-behind file i can't call categories(); 但是在我的代码隐藏文件中,我无法调用category(); I have referenced the repositories path. 我已经参考了存储库路径。

How should i use the public method to be used in multiple pages from my repositories? 我应该如何使用公共方法在存储库中的多个页面中使用?

我认为您忘了add reference

Sounds like a C# issue - probably nothing to do with Fluent NHibernate. 听起来像是C#问题-可能与Fluent NHibernate无关。

Maybe you forgot to add the parenthesis when you call the method? 也许在调用该方法时忘记添加括号了吗? eg 例如

categories, instead of categories() 类别,而不是category()

It would help if you showed more of your code - like the declaration of the categories member, and where you are trying to call it. 如果您显示更多代码,例如类别成员的声明以及在何处调用它,这会有所帮助。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

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