CTP5 Code First Filter By字符串参数 [英] CTP5 Code First Filter By string parameter

查看:76
本文介绍了CTP5 Code First Filter By字符串参数的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述


您好,



我是Code First的新手所以可能这个问题很简单。



 




//我能够使用TableView字符串找到一个DbSet< x> 形式
mycontext(例如"PERSON"):


var
set1 = mycontext
。GetType()。GetProperty(TableView).GetValue(mycontext
null );


//我可以使用



 



 



var
obsc = set1.GetType()。GetProperty(
" Local" )。GetValue(set1,
null );


//但我目前无法通过sting参数找到过滤set1的方法,例如


string filter =" NAME = PIPPO"


欢迎任何想法


谢谢


 



 



 




 



解决方案

嗨Pomini,


WPF中基于代码的过滤通常使用CollectionView类完成。 这是一个简单的例子:


  var  filteredObsc =  new  ListCollectionView (obsc); 
filteredObsc.Filter = p =>((Person)p).Name == " PIPPO" ;


Hello,

I am new on Code First so may be this question is very simple.

 

//I am able to find a DbSet<x> form mycontext using TableView string (for example "PERSON"):

var set1 = mycontext.GetType().GetProperty(TableView).GetValue(mycontext, null);

//and I can bind to WPF grid ItemsSource as Observable collection using

 

 

var obsc = set1.GetType().GetProperty("Local").GetValue(set1, null);

//but I not able at the moment to find a way to filter set1 by sting parameter for example

string filter = "NAME = PIPPO"

Any ideas are welcome

Thanks

 

 

 

 

解决方案

Hi Pomini,

Code-based filtering in WPF is typically done with the CollectionView class. Here is a simple example:

var filteredObsc = new ListCollectionView(obsc);
filteredObsc.Filter = p => ((Person)p).Name == "PIPPO";


这篇关于CTP5 Code First Filter By字符串参数的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆