Venkat Govind

Venkat Govind

  • 1.2k
  • 491
  • 64.3k

No mapping exists from object type AdPlanner.Models.Admin.Region to a

Nov 18 2023 12:43 PM

below code

string constr = @"Data Source=CHLAPDVENCHAL\SQLEXPRESS;Initial Catalog=AdPlanner;Integrated security=true"; 
using (SqlConnection conn = new SqlConnection(constr)) 
{ 
// using (SqlConnection conn = new SqlConnection()) 
//{ 
// conn.ConnectionString = "Server=CHLAPDVENCHAL\\SQLEXPRESS;Database=AdPlanner;
Integrated Security=True"; 
// using the code here...
// conn.Open(); 
// SqlConnection con = new SqlConnection("Data Source= CHLAPDVENCHAL\\SQLEXPRESS;Initial Catalog=AdPlanner;Integrated Security=True;"); 
SqlCommand cmd = new SqlCommand("InsertInputfieldconfig", conn); 
cmd.CommandType = CommandType.StoredProcedure; 
cmd.Parameters.AddWithValue("@AccountID", inputfieldconfigModel.AccountId); 
cmd.Parameters.AddWithValue("@RegionfieldConfig", inputfieldconfigModel.Region); 
cmd.Parameters.AddWithValue("@MarketfieldConfig", inputfieldconfigModel.MarketModel); 
cmd.Parameters.AddWithValue("@StorefieldConfig", inputfieldconfigModel.StoreModel); 
cmd.Parameters.AddWithValue("@ItemfieldConfig", inputfieldconfigModel.ItemModel); 
cmd.Parameters.AddWithValue("@ItemPricefieldConfig", inputfieldconfigModel.ItemPriceModel); 
cmd.Parameters.AddWithValue("@PGroupfieldConfig", inputfieldconfigModel.PGroupModel); 
cmd.Parameters.AddWithValue("@OfferfieldConfig", inputfieldconfigModel.OfferModel); 
cmd.Parameters.AddWithValue("@CreatedBy", inputfieldconfigModel.CreatedBy); 
cmd.Parameters.AddWithValue("@QueryType", inputfieldconfigModel.QueryType); 
cmd.Parameters.AddWithValue("@CreatedOn", inputfieldconfigModel.CreatedOn); 
int k = cmd.ExecuteNonQuery(); 
if (k != 0) 
{ 
return new Response 
{ 
Message = "Record Inserted Succesfully into the Database", IsError = true }; 
} 
else 
{ 
return new Response 
{ 
Message = "Error", IsError = true }; 
} 

Model 

public class inputfields 
{ 
public int AccountId { get; set; } 
public int IfcID { get; set; } 
public string? CreatedBy { get; set; } 
public string? QueryType { get; set; } 
public DateTime? CreatedOn { get; set; } 
public Region Region { get; set; } 
public StoreModel StoreModel { get; set; } 
public MarketModel MarketModel { get; set; } 
public ItemPriceModel ItemPriceModel { get; set; } 
public ItemModel ItemModel { get; set; } 
public PGroupModel PGroupModel { get; set; } 
public OfferModel OfferModel { get; set; } 
} 
public class Region 
{ 
public List CommonFields { get; set; } 
public List CustomFields { get; set; } 
} 
public class CommonFieldsModel 
{ 
public string FieldName { get; set; } 
public bool Visibility { get; set; } 
public string DisplayName { get; set; 
} 
public bool RequiredInIngestion { get; set; } 
} 
public class CustomFieldsModel 
{ 
public string FieldName { get; set; } 
public string ControlType { get; set; } 
public string ControlTypeLable { get; set; } 
public string DisplayName { get; set; } 
public string DataType { get; set; } 
public string DataTypeLable { get; set; } 
public string FieldLength { get; set; } 
public string Tooltip { get; set; } 
public string IsMandatory { get; set; } 
public string IsReadonly { get; set; } 
public string isDeleted { get; set; } 
public string ErrorMessage { get; set; } 
public string IsMultiSelect { get; set; } 
public string Value { get; set; } 
public string Options { get; set; } 
}

 


Answers (1)