Fields not displaying in a view (or displaying a weird date format

  • Thread starter Thread starter SSIS_Newbie_1234
  • Start date Start date
S

SSIS_Newbie_1234

Guest
Someone else wrote the code and I'm asked to look after it.

OK - there is a simple web page on a c#.NET website.
It ~should~ be based on a view called "[SVR.Database].[dbo].[EmployeeAttendeesFromOutsideUk]"

At to a certain extent it is - if you, for example, change the view, the the many hundreds of other objects that c#sharp pointlessly forces you to change, then the changes you make, are reflected in the view.

As an example, because I'm having issues with a Visit Date column, I got shot of it, and added two columns instead "Visit Date Convert" and "Visit Date No Convert".
In SQL, the view displays correctly ALL the data:
Id, SiteId, Employee Name, - every field, is populated, and populated correctly.

C~ seems to be mucking it up:
Doesn't display anything Except Id, Upin, Subsidary, and Days Visited.
All the other fields are missing. At one stage it displayed the vist date (incorrectly as 01.01.0001 01:01:01:01) instead of the actual visit date as displayed in the view.

The code that populates it is almost impossible to interpret, its like this:

return base.GetListItems(siteId, options, _reportsRepository.GetVisitorsFromOutsideUK,
new Expression<Func<NonUkAttendee, dynamic>>[]
{
x => x.SiteId,
x => x.FullName,
x => x.VisitDateConvert,
x => x.VisitDateNoConvert,
//x => DateTime.Now.ToShortTimeString(),
x => x.Upin,
x => x.Organisation,
x => x.Subsidiary,
x => x.Hospitality,
x => x.CostCentre,
x => x.DaysVisited
},
SVRUserRole.Roles.Facilities);

i.e Complete gibberish.

Anyway care to explain what x is?
Any ideas why C Sharp can't perform the basic task "display me data in an SQL view". I've done all the work for it.
Here's some more of the code. There is endless streams of it, all over the place, typically making it very difficult to work with:

public ActionResult InlandRevenue(string siteId, OptionsViewModel options)
{
const string dateColumn = "Visit Date No Convert";
const string dateColumn2 = "Visit Date No Convert";
// DateTime dateColumn2 = Convert.ToDateTime("Visit Date");
//string dateColumn = "Visit Date";

options.CurrentSiteId = options.CurrentSiteId ?? siteId;
options.LinkToController = "People";
options.LinkToAction = "Person";
options.Title = "Title of view";
options.Filters.Clear();

var taxYearSelection = DateRangeQuickSelection.CurrentUKTaxYear();

var dateRangeFilter = new DateRangeFilterProvider
{
PropertyName = dateColumn,
//PropertyName = dateColumn2,
//PropertyName = Convert.ToDateTime(dateColumn),
DefaultDateFrom = taxYearSelection.DateFrom,
DefaultDateTo = taxYearSelection.DateTo
};

dateRangeFilter.DateRangeQuickSelections.AddRange(
new[]
{
taxYearSelection
});

options.Filters.Add(dateRangeFilter);

if (string.IsNullOrEmpty(options.SortOn))
{
options.SortOn = dateColumn;
options.SortOn = dateColumn.ToString();
options.SortOn = dateColumn;
options.SortAscending = false;
//options.
}

1502885.png

Continue reading...
 
Back
Top