public static bool CheckNickName(string FNickName) { //判断昵称是否已存在 bool ExistNickName = ModelOpretion.ScalarDataExist(@" Select * From e_MobileUser where FNickName=@FNickName ", new { FNickName = FNickName.Trim() }); return(ExistNickName); }
public static bool CheckMobile(string FMobile) { //判断手机号是否已存在 bool ExistMobile = ModelOpretion.ScalarDataExist(@" Select * From e_MobileUser where FMobile=@FMobile ", new { FMobile = FMobile.Trim() }); return(ExistMobile); }
public static bool CheckAccount(string FAccount) { //用户名是否已存在 bool ExistAccount = ModelOpretion.ScalarDataExist(@" Select * From e_MobileUser where FAccount=@FAccount ", new { FAccount = FAccount.Trim() }); return(ExistAccount); }
public TResult Execute <TResult>(Expression expression) { object obj2; var base2 = ProviderFactory.CreateProvider(dc.dbconn(string.Empty).Reader.DatabaseType); var result = ParseExpression(expression); var type = typeof(TResult); //SqlExecutorBase base3 = base2.CreateSqlExecutor(); if ((expression.NodeType != ExpressionType.Call) || !type.IsValueType) { var flag = false; if (type.IsGenericType) { var reader = ModelOpretion.SearchDataRetunDataTable(result.CommandText, result.SqlQueryParameters, null); //base3.ExecuteReader(result.CommandText, result.Parameters); if (type.GetGenericTypeDefinition() == ReflectorConsts.IEnumerableType) { var objectType = type.GetGenericArguments()[0]; IList list = null; try { list = EntityMapper.Map(objectType, reader, base2.ObjectPropertyConvertType); } catch { throw new Exception("转化成TResult失败"); } return((TResult)list); } if (typeof(Nullable <>).IsAssignableFrom(type)) { flag = true; } if (!flag) { throw new Exception(); } } if (type.IsValueType | flag) { var obj = ModelOpretion.ScalarBache(result.CommandText, result.SqlQueryParameters, null); if (obj == null) { return(default(TResult)); } if (obj == DBNull.Value) { return(default(TResult)); } return((TResult)Convert.ChangeType(obj, type)); } if (!EntityConfigurationManager.IsEntity(type)) { throw new Exception(); } var dataReader = ModelOpretion.SearchDataRetunDataTable(result.CommandText, result.SqlQueryParameters, null); IList list2 = null; try { list2 = EntityMapper.Map(type, dataReader, base2.ObjectPropertyConvertType); } catch (Exception ex) { throw new Exception("TResult:转化成实体失败."); } finally { } if (list2.Count <= 0) { return(default(TResult)); } var entity = list2[0]; return((TResult)entity); } //var name = ((MethodCallExpression) expression).Method.Name; //if (name != "Any") //{ // if ((name != "Delete") && (name != "Update")) // { // if ((name != "Average") && (name != "Sum") && (name != "Count")) // { // throw new Exception(); // } // obj2 = base3.ExecuteScalar(result.CommandText, result.Parameters); // if (obj2 == DBNull.Value) // { // return default(TResult); // } // var converter1 = new BaseTypeConverter(obj2, type); // converter1.Process(); // return (TResult) converter1.Result; // } //} //else //{ // DataSet set = base3.ExecuteDataSet(result.CommandText, result.Parameters); // obj2 = set.Tables.Count <= 0 ? 0 : (object) (set.Tables[0].Rows.Count > 0); // return (TResult) obj2; //} obj2 = ModelOpretion.ScalarBache(result.CommandText, result.SqlQueryParameters, null); return((TResult)obj2); }
public List <TElement> FindAs <TElement>(Expression <Func <TElement, bool> > lambdawhere) { return(ModelOpretion.ModelListInstance <TElement>(lambdawhere)); }