public DataSourceMasterModel GetDataSourceMasterByPrimaryKey(Int64 MasterReport_Id)
        {
            DataSourceMaster result = this.dataContext
                                      .DataSourcesMaster
                                      .FirstOrDefault(pk => pk.MasterReport_Id == MasterReport_Id);

            if (result == null)
            {
                return(null);
            }

            return(result.CopyToObject(new DataSourceMasterModel()) as DataSourceMasterModel);
        }
        public void UpdateDataSourceMaster(DataSourceMasterModel model)
        {
            DataSourceMaster existing = this.dataContext
                                        .DataSourcesMaster
                                        .Where(rx => rx.MasterReport_Id == model.MasterReport_Id)
                                        .FirstOrDefault();

            if (existing == null)
            {
                existing = model.CopyToObject(new DataSourceMaster()) as DataSourceMaster;

                this.dataContext.DataSourcesMaster.Add(existing);
            }
            else
            {
                existing = model.CopyToObject(existing) as DataSourceMaster;
            }

            this.dataContext.SaveChanges();

            model = existing.CopyToObject(model) as DataSourceMasterModel;
        }