我正在c#中编写一个web服务,我在其中反序列化对象并使用Entity Frame工作保存在DB中。我正在调用方法GetFormData(refNo,form6a,ref form6aEntity,ref form6aDocs),其中form6a是反序列化对象,而from6a实体是实体框架生成的类。这个metod只是将数据从form6对象映射到form6aEntity对象。
if (new ECI.Handler.Form6aHandler().GetFormData(refNo, form6a, ref form6aEntity, ref form6aDocs))
{
// stateCode = form6aEntity.ST_CODE;
// acNo = Convert.ToInt32(form6aEntity.AC_NO);
stateCode = form6aEntity.ST_CODE;
dbIps = new DBO().GetDbMap(stateCode);
foreach (string dbip in dbIps.Keys)
{
fornDbIp = dbip;
}
foreach (string aip in dbIps.Values)
{
attachmentDbIP = aip;
}
connectionString.Add("Forms", string.Format(ConfigurationSettings.AppSettings["NERMSConnString"].ToString(), fornDbIp, "All"));
connectionString.Add("Attachments", string.Format(ConfigurationSettings.AppSettings["NERMS_AttachmentConnString"].ToString(), attachmentDbIP, "All"));
formSaveStatus = new DBO().UpdateForm6A(form6aEntity, form6aDocs, connectionString);
}
}
方法定义类似于
public bool GetFormData(string formRefNo, Form6A formData, ref DBMLs.Form6a formEntity, ref ECI.DBMLs.Form6a_attachment formDocs)
{
bool status = false;
try
{
formDocs.AC_NO = Convert.ToInt32(formData.header.constituency_no);
formData.attachment.applicant_passport = formData.attachment.applicant_passport.Replace("data:image/jpeg;base64,", string.Empty);
formDocs.applicant_passport = Convert.FromBase64String(formData.attachment.applicant_passport);
formData.attachment.applicant_photo = formData.attachment.applicant_photo.Replace("data:image/jpeg;base64,", string.Empty);
formDocs.applicant_photo = Convert.FromBase64String(formData.attachment.applicant_photo);
formDocs.REF_NO = formRefNo;
formDocs.ST_CODE = formData.header.state_code;
if (!string.IsNullOrWhiteSpace(formData.absent.since))
formEntity.ABSENT_DATE = DateTime.ParseExact(formData.absent.since, "dd-mm-yyyy",
System.Globalization.CultureInfo.InvariantCulture);
//formEntity.ABSENT_DATE = formData.absent.since.ToNullable<DateTime>();
formEntity.ABSENT_REASON = formData.absent.reason;
formEntity.AC_NO = Convert.ToInt32(formData.header.constituency_no);
formEntity.APPLICANT_DATE = DateTime.ParseExact(formData.declaration.applicant_date, "dd-mm-yyyy",
System.Globalization.CultureInfo.InvariantCulture);
//formEntity.APPLICANT_DATE = formData.declaration.applicant_date.ToNullable<DateTime>();
formEntity.APPLICANT_PLACE = formData.declaration.applicant_place;
formEntity.BIRTH_DISRTICT = formData.elector.birth_district;
formEntity.BIRTH_PLACE = formData.elector.birth_place;
formEntity.BIRTH_STATE = formData.elector.birth_state;
formEntity.BIRTH_VILLAGE = formData.elector.birth_village;
formEntity.DISTRICT_CODE = Convert.ToInt32(formData.address.district);
if (!string.IsNullOrWhiteSpace(formData.elector.dob))
formEntity.DOB = DateTime.ParseExact(formData.elector.dob, "dd-mm-yyyy",
System.Globalization.CultureInfo.InvariantCulture);
//formEntity.DOB = Convert.ToDateTime(formData.elector.dob);
formEntity.EMAIL_ID = formData.declaration.email_id;
formEntity.FNAME_EN = formData.elector.name;
formEntity.FNAME_V1 = formData.elector.name_v;
formEntity.GENDER = formData.elector.gender;
formEntity.HOUSE_NO = formData.address.house_no;
formEntity.LNAME_EN = formData.elector.lname;
formEntity.LNAME_V1 = formData.elector.lname_v;
formEntity.MNAME_EN = formData.elector.mname;
formEntity.MNAME_V1 = formData.elector.mname_v;
formEntity.MOBILE_NO = formData.declaration.mobile_no;
formEntity.O_ADDRESS_ABROAD = formData.abroad_add.official;
if (!string.IsNullOrWhiteSpace(formData.passport.expiry_date))
formEntity.PASSPORT_EXPIRY_DATE = DateTime.ParseExact(formData.passport.expiry_date, "dd-mm-yyyy",
System.Globalization.CultureInfo.InvariantCulture);
//formEntity.PASSPORT_EXPIRY_DATE = formData.passport.expiry_date.ToNullable<DateTime>();
if (!string.IsNullOrWhiteSpace(formData.passport.issue_date))
formEntity.PASSPORT_ISSUE_DATE = DateTime.ParseExact(formData.passport.issue_date, "dd-mm-yyyy",
System.Globalization.CultureInfo.InvariantCulture);
//formEntity.PASSPORT_ISSUE_DATE = formData.passport.issue_date.ToNullable<DateTime>();
formEntity.PASSPORT_ISSUE_PLACE = formData.passport.issue_place;
formEntity.PASSPORT_NO = formData.passport.no;
formEntity.PIN_CODE = Convert.ToDecimal(formData.address.pincode);
formEntity.POST_OFFICE = formData.address.postoffice;
formEntity.PREV_AC_NAME = formData.prev_epic.constituency;
//formEntity.PREV_EPIC_EXISTS = Convert.ToBoolean(formData.prev_epic.exists);
formEntity.PREV_EPIC_EXISTS = formData.prev_epic.exists == "1" ? true : false;
if (!string.IsNullOrWhiteSpace(formData.prev_epic.issue_date))
formEntity.PREV_EPIC_ISSUE_DATE = DateTime.ParseExact(formData.prev_epic.issue_date, "dd-mm-yyyy",
System.Globalization.CultureInfo.InvariantCulture);
// formEntity.PREV_EPIC_ISSUE_DATE = formData.prev_epic.issue_date.ToNullable<DateTime>();
formEntity.PREV_EPIC_NO = formData.prev_epic.no;
formEntity.PREV_PLACE = formData.prev_epic.place;
formEntity.PREV_STATE = formData.prev_epic.state;
formEntity.R_ADDRESS_ABROAD = formData.abroad_add.residential;
formEntity.REF_NO = formRefNo;
formEntity.RLN_FNAME_EN = formData.relative.name;
formEntity.RLN_FNAME_V1 = formData.relative.name_v;
formEntity.RLN_LNAME_EN = formData.relative.lname;
formEntity.RLN_LNAME_V1 = formData.relative.lname_v;
formEntity.RLN_MNAME_EN = formData.relative.mname;
formEntity.RLN_MNAME_V1 = formData.relative.mname_v;
formEntity.RLN_TYPE = formData.relative.type;
formEntity.ST_CODE = formData.header.state_code;
formEntity.STREET_AREA = formData.address.street;
formEntity.TEHSIL = formData.address.tehsil;
formEntity.VILLAGE = formData.address.town;
if (!string.IsNullOrWhiteSpace(formData.visa.expiry_date))
formEntity.VISA_EXPIRY_DATE = DateTime.ParseExact(formData.visa.expiry_date, "dd-mm-yyyy",
System.Globalization.CultureInfo.InvariantCulture);
//formEntity.VISA_EXPIRY_DATE = formData.visa.expiry_date.ToNullable<DateTime>();
if (!string.IsNullOrWhiteSpace(formData.visa.issue_date))
formEntity.VISA_ISSUE_DATE = DateTime.ParseExact(formData.visa.issue_date, "dd-mm-yyyy",
System.Globalization.CultureInfo.InvariantCulture);
//formEntity.VISA_ISSUE_DATE = formData.visa.issue_date.ToNullable<DateTime>();
formEntity.VISA_ISSUE_PLACE = formData.visa.issue_place;
formEntity.VISA_ISSUING_AUTHORITY = formData.visa.issuing_authority;
formEntity.VISA_NO = formData.visa.no;
formEntity.VISA_TYPE = formData.visa.type;
formEntity.FORM_SUBMISSION_DATE = DateTime.ParseExact(formData.declaration.applicant_date, "dd-mm-yyyy",
System.Globalization.CultureInfo.InvariantCulture);
status = true;
}
catch (Exception ex)
{
Console.WriteLine(ex.Message);
status = false;
}
return status;
}
}
编译时,我收到以下错误:
编译器错误消息:CS1502:'ECI.Handler.Form6aHandler.GetFormData(字符串,ECI.Forms.Form6a.Form6A,参考ECI.DBMLs.Form6a,参考ECI.DBMLs.Form6a_attachment)的最佳重载方法匹配)'有一些无效的论点 Screen shot of error
参数Form6a:
public class Form6A
{
public Form6A() {
this.header = new Header();
this.elector = new Elector();
this.relative = new Relative();
this.address = new Address();
this.passport = new Passport();
this.visa = new Visa();
this.absent = new Absent();
this.abroad_add = new AbroadAdd();
this.prev_epic = new PrevEpic();
this.declaration = new Declaration();
this.attachment = new Attachment();
}
public Header header { get; set; }
public Elector elector { get; set; }
public Relative relative { get; set; }
public Address address { get; set; }
public Passport passport { get; set; }
public Visa visa { get; set; }
public Absent absent { get; set; }
public AbroadAdd abroad_add { get; set; }
public PrevEpic prev_epic { get; set; }
public Declaration declaration { get; set; }
public Attachment attachment { get; set; }
public override string ToString()
{
StringBuilder s = new StringBuilder();
s.Append(this.header.ToString() + ",");
s.Append(this.elector.ToString() + ",");
s.Append(this.relative.ToString() + ",");
s.Append(this.address.ToString() + ",");
s.Append(this.passport.ToString() + ",");
s.Append(this.visa.ToString() + ",");
s.Append(this.absent.ToString() + ",");
s.Append(this.abroad_add.ToString() + ",");
s.Append(this.prev_epic.ToString() + ",");
s.Append(this.declaration.ToString() + ",");
s.Append(this.attachment.ToString());
return s.ToString();
}
}
表单实体
[global::System.Data.Linq.Mapping.TableAttribute(Name="dbo.Form6a")]
public partial class Form6a : INotifyPropertyChanging, INotifyPropertyChanged
{
private static PropertyChangingEventArgs emptyChangingEventArgs = new PropertyChangingEventArgs(String.Empty);
private string _REF_NO;
private string _ST_CODE;
private int _AC_NO;
private System.Nullable<int> _PART_NO;
private string _FNAME_EN;
private string _FNAME_V1;
private string _FNAME_V2;
private string _FNAME_V3;
private string _FNAME_V4;
private string _MNAME_EN;
private string _MNAME_V1;
private string _MNAME_V2;
private string _MNAME_V3;
private string _MNAME_V4;
private string _LNAME_EN;
private string _LNAME_V1;
private string _LNAME_V2;
private string _LNAME_V3;
private string _LNAME_V4;
private System.Nullable<System.DateTime> _DOB;
private string _GENDER;
private string _BIRTH_PLACE;
private string _BIRTH_VILLAGE;
private string _BIRTH_DISRTICT;
private string _BIRTH_STATE;
private string _RLN_TYPE;
private string _RLN_FNAME_EN;
private string _RLN_FNAME_V1;
private string _RLN_FNAME_V2;
private string _RLN_FNAME_V3;
private string _RLN_FNAME_V4;
private string _RLN_MNAME_EN;
private string _RLN_MNAME_V1;
private string _RLN_MNAME_V2;
private string _RLN_MNAME_V3;
private string _RLN_MNAME_V4;
private string _RLN_LNAME_EN;
private string _RLN_LNAME_V1;
private string _RLN_LNAME_V2;
private string _RLN_LNAME_V3;
private string _RLN_LNAME_V4;
private string _SECTION_NO;
private string _HOUSE_NO;
private string _STREET_AREA;
private string _VILLAGE;
private string _POST_OFFICE;
private System.Nullable<decimal> _PIN_CODE;
private string _TEHSIL;
private System.Nullable<int> _DISTRICT_CODE;
private System.Nullable<bool> _PREV_EPIC_EXISTS;
private string _PREV_EPIC_NO;
private string _PREV_STATE;
private string _PREV_AC_NAME;
private string _PREV_PLACE;
private System.Nullable<System.DateTime> _PREV_EPIC_ISSUE_DATE;
private string _APPLICANT_PLACE;
private System.Nullable<System.DateTime> _APPLICANT_DATE;
private string _MOBILE_NO;
private string _EMAIL_ID;
private string _PASSPORT_NO;
private string _PASSPORT_ISSUE_PLACE;
private System.Nullable<System.DateTime> _PASSPORT_ISSUE_DATE;
private System.Nullable<System.DateTime> _PASSPORT_EXPIRY_DATE;
private string _VISA_NO;
private string _VISA_TYPE;
private System.Nullable<System.DateTime> _VISA_ISSUE_DATE;
private string _VISA_ISSUE_PLACE;
private System.Nullable<System.DateTime> _VISA_EXPIRY_DATE;
private string _VISA_ISSUING_AUTHORITY;
private string _ABSENT_REASON;
private System.Nullable<System.DateTime> _ABSENT_DATE;
private string _R_ADDRESS_ABROAD;
private string _O_ADDRESS_ABROAD;
private System.Nullable<System.DateTime> _FORM_SUBMISSION_DATE;
private System.Nullable<bool> _IS_OFFLINE;
private System.Data.Linq.Binary _APPLICANT_PHOTO;
private System.Nullable<bool> _IS_SUBMITTED_TO_STATE;
private System.Nullable<int> _RETRIAL_COUNT;
private string _HOUSE_NO_V1;}
Form6Docs
public partial class Form6_attachment : INotifyPropertyChanging, INotifyPropertyChanged
{
private static PropertyChangingEventArgs emptyChangingEventArgs = new PropertyChangingEventArgs(String.Empty);
private long _ID;
private string _REF_NO;
private string _ST_CODE;
private int _AC_NO;
private System.Data.Linq.Binary _applicant_photo;
private System.Data.Linq.Binary _dob_proof;
private System.Data.Linq.Binary _residence_proof;}