can i set value for a property like this
public string MyProperty { get { return _GetValue(); } set { _GetValue(); } }
public static string _GetValue()
{
string name = null;
using (HROEF.Entities context = new HROEF.Entities())
{
var result = (from my linq Statement).First().ToString();
name = result;
}
return name;
}
In my View
@Html.DisplayFor(model=>Model.MyProperty)
is there any thing wrong in this?
It is not displaying the value in my view
any help?
In general, you shouldn’t be doing database accessin properties. It’s just bad practice. Properties should not perform lengthy operations that can time out, or have other issues.
As for why it’s not showing your value, that’s hard to say. Most likely, your linq query simply isn’t returning any results.