Sınıf kitaplığı projesinde Product
adlı bir sınıf var. Nesneleri sürdürmek için SubSonic SimpleRepository
kullanıyorum.'Product' türünün kapsamdan başvurulan 'x', ancak tanımlanmamış
public static IList<Product> Load(Expression<Func<Product, bool>> expression)
{
var rep=RepoHelper.GetRepo("ConStr");
var products = rep.Find(expression);
return products.ToList();
}
bu böyle işlevini çağırıyorum: Product
sınıfında aşağıdaki gibi bir yöntem var
variable 'x' of type 'Product' referenced from scope '', but it is not defined
Nasıl: BindData
den Load
çağrılması
private void BindData()
{
var list = Product.Load(x => x.Active);//Active is of type bool
rptrItems.DataSource = list;
rptrItems.DataBind();
}
istisna atar Bunu çözüyorum.
DÜZENLEME: - SubSonic
kod boyunca adım atma hata günlerce duvara kafamı beceriyor ve hatta yardım Jon Skeet soran sonra bu işlevin
private static Expression Evaluate(Expression e)
{
if(e.NodeType == ExpressionType.Constant)
return e;
Type type = e.Type;
if(type.IsValueType)
e = Expression.Convert(e, typeof(object));
Expression<Func<object>> lambda = Expression.Lambda<Func<object>>(e);
Func<object> fn = lambda.Compile(); //THIS THROWS EXCEPTION
return Expression.Constant(fn(), type);
}
SubSonic'te bir hataya benziyor. (@Kobi: Hayır) – Timwi
@Timwi herhangi bir geçici çözüm bu? – TheVillageIdiot