//Main Program - Calling the GetResults Method
string mesaiBitisSaati = CommonClass.GetResults<string>(SystemCodes.MZB, 1);
//CommonClass
- GetOneResult Method
public static T GetResults<T>(SystemCodes sistemKodu, decimal parametreKodu)
{
try
{
object param = GetOneResult(sistemKodu, parametreKodu);
return (T)Convert.ChangeType(param, typeof(T));
}
catch
{
return default(T);
}
}
//CommonClass - GetOneResult Method
public static string GetOneResult(SystemCodes sistemKodu, decimal parametreKodu)
{
try
{
using (ProbelTESTEntities context = EntityProvider<ProbelTESTEntities>.NewContainer())
{
TEST_TABLE param = context.TEST_TABLE.Where(x
=> x.SISTEM_ID == (decimal)sistemKodu &&
x.DEPARTMENT_ID == CommonInfos.ActiveUser.Department.Id
&&
x.KODU == parametreKodu)
.SingleOrDefault();
return param.Assigned() ?
param.DEGERI.ToUpper() : null;
}
}
catch
{
return null;
}
}
Comments
Post a Comment