Skip Navigation Links.

Northwind\Data\CustomValidators.cs

D:\NorthwindForWeb\Northwind\CS\DotNet\ADO.Net\Northwind\Data\CustomValidators.cs
/*
 * This file was generated by ProCG version 2.0
 *
 * File name:	Northwind\Data\CustomValidators.cs
 * Language:	C# - ADO.Net 
 * Database:	My Sql
 *
 * Copyright (c) 2002-2019 iGenXSoft.
 * For more information visit http://www.igenxsoft.com
 */


using FluentValidation;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace Northwind.Data
{
	public static class CustomValidators
	{
		public static IRuleBuilderOptions<T, TElement> MustBeInEnum<T, TElement>(this IRuleBuilder<T, TElement> ruleBuilder, Type enumToCheckWith)
		{
			return ruleBuilder.Must(element => IsInEnum(enumToCheckWith, element)).WithMessage("TableCode does not exist in Enum");
		}

		public static bool IsInEnum(Type enumToCheckWith, object value)
		{
			int fieldValue = Convert.ToInt32(value);
			foreach (int i in Enum.GetValues(enumToCheckWith))
			{
				if (fieldValue == i)
					return true;
			}
			return false;
		}
	}
}



  //      1079 ProCG uses this line - don't edit it

2020 © iGenXSoft ProCG Generated Codes
pompy wtryskowe|cheap huarache shoes| bombas inyeccion|cheap jordans|cheap air max| cheap sneaker|wholesale jordans|cheap china jordans|cheap wholesale jordans