开发者

System.Linq.Dynamic ´s .Where will be misinterpreted

I've build a large program with many references. F.e.:

  • System.Data.DataSetExtensions
  • System.Linq.Dynamic

I've to write a Dynamic Linq Expression:

http://weblogs.asp.net/scottgu/archive/2008/01/07/dynamic-linq-part-1-using-the-linq-dynamic-query-library.aspx

In my case:

Dim que开发者_如何学Cry As IEnumerable = ds.Sales.Where(strWhere)

But with System.Data.DataSetExtensions Where is misinterpreted. The compiler expects (Datarow, Integer, Boolean). If I delete System.Data.DataSetExtensions everything is ok with this expression, but I get many other errors, so I need this reference.

What can I do that the Where is interpreted correctly?


Is the large programm all in one file?

If not done already, split up your program into classes, then put each class into it's own file. Then only use the required references in every file.

Maybe this way you will be able to resolve the namespace conflict.

If for some reason you absolutely need both conflicting namespaces and can't resolve the ambiguity, you can directly call the extension method. Basically the extension method is just another static method on another class. ds.Sales.Where(strWhere) is only syntactic sugar for that method call.

An example:

ds.Sales.AsEnumerable().Where(yourCondition)

Would translate to

EnumerableRowCollectionExtensions.Where(ds.Sales.AsEnumerable(), yourCondition)
0

上一篇:

下一篇:

精彩评论

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

最新问答

问答排行榜