public void Build(IDbDataParameter adoParameter) { IBindingMetadata metadata = this.Source?.Identity.Metadata.Require <IBindingMetadata>(); IBindingParameterContract contract = metadata?.Parameter; adoParameter.ParameterName = this.Name; if (contract?.Convert != null) { adoParameter.Value = contract.Convert(this.Source?.Snapshot); } else if (this.Source != null) { adoParameter.Value = this.Source.Snapshot; } else { adoParameter.Value = DBNull.Value; } if (contract?.Write != null) { BindingParameterInfo paramInfo = new BindingParameterInfo() { Metadata = metadata, Parameter = adoParameter, Field = this.Source, }; contract.Write(paramInfo); } }
public void Build(IDbDataParameter adoParameter) { IBindingMetadata metadata = this.Field?.Identity.GetMetadata <IBindingMetadata>(); IBindingParameterContract contract = metadata?.Parameter; adoParameter.ParameterName = this.Name; if (contract?.Convert != null) { adoParameter.Value = contract.Convert(this.Field?.Value); } else if (this.Field != null) { adoParameter.Value = this.Field.Value; } else { adoParameter.Value = DBNull.Value; } if (contract?.Write != null) { BindingParameterInfo paramInfo = new BindingParameterInfo() { Metadata = metadata, Parameter = adoParameter, Field = this.Field, }; contract.Write(paramInfo); } }
public static IDbDataParameter CreateAdoParameter(IDbCommand adoCommand, IParameter parameter) { IDbDataParameter adoParameter = adoCommand.CreateParameter(); IBindingMetadata metadata = parameter.Field?.Identity.GetMetadata <IBindingMetadata>(); IBindingParameterContract contract = parameter.Contract ?? metadata?.Parameter; adoParameter.ParameterName = parameter.Name; if (contract?.Convert != null) { adoParameter.Value = contract.Convert(parameter.Field?.Value); } else if (parameter.Field != null) { adoParameter.Value = parameter.Field.Value; } else { adoParameter.Value = DBNull.Value; } if (contract?.Write != null) { BindingParameterInfo paramInfo = new BindingParameterInfo() { Metadata = metadata, Parameter = adoParameter, Field = parameter.Field, }; contract.Write(paramInfo); } return(adoParameter); }