I have a class which has a many to many relationship with student. Please bare in mind this is a xarmain forms application talking to the client using NewtownSoft
public class Booking
{
public int Id { get; set; }
public int? DayOfWeek { get; set; }
public DateTime? BookingDate { get; set; }
public bool? IsAbsent { get; set; }
public DateTime? Time { get; set; }
public bool? HasCheckedIn { get; set; }
public ICollection<Student> Students { get; set; }
public bool? IsDeleted { get; set; }
public bool? IsActive { get; set; }
public string? CreatedBy { get; set; }
public string? LastModifiedBy { get; set; }
public DateTime? LastUpdatedDate { get; set; }
public DateTime? CreatedDate { get; set; }
}
Student Class
public class Student
{
public int Id { get; set; }
public int? Type { get; set; }
public string? FirstName { get; set; }
public string? Surname { get; set; }
public DateTime? DOB { get; set; }
public decimal? Weight { get; set; }
public decimal? Height { get; set; }
public int? Gender { get; set; }
public string? Photo { get; set; }
public int? Age { get; set; }
public ICollection<Booking> Bookings { get; set; }
public bool? IsDeleted { get; set; }
public ICollection<Notes>? Notes { get; set; }
public decimal? TB { get; set; }
public decimal? OP { get; set; }
public decimal? PU { get; set; }
public decimal? PB { get; set; }
public decimal? BP { get; set; }
public bool? IsActive { get; set; }
public string? CreatedBy { get; set; }
public string? LastModifiedBy { get; set; }
public DateTime? LastUpdatedDate { get; set; }
public DateTime? CreatedDate { get; set; }
}
I am adding that student to my api in the following way from the button click event.
private async void btnBookStudent_Clicked(object sender, EventArgs e)
{
//if we want the booking to include our student we must add it to our colleciton.
var test = Helpers.Dates.GetDateZeroTime(selectedBookingDate.Date).Add(timePicker.Time);
var student = await api.GetStudentById(StudentId);
var newBooking = new Booking
{
IsAbsent = false,
IsActive = true,
IsDeleted = false,
Time = Helpers.Dates.
GetDateZeroTime(selectedBookingDate.Date).
Add(timePicker.Time),
DayOfWeek = DayNumber
};
newBooking.Students = new List<Student>();
newBooking.Students.Add(student);
await api.AddToBooking(newBooking);
await DisplayAlert(Constants.AppName, "Booking Created For
Student", "OK");
}
However my client application is crashing out and not producing an error.
public async Task<HttpStatusCode> AddToBooking(Booking booking)
{
HttpStatusCode statusCode = new HttpStatusCode();
List<string> errors = new List<string>();
var serializerSettings = new JsonSerializerSettings {
ReferenceLoopHandling =
Newtonsoft.Json.ReferenceLoopHandling.Serialize};
string json =
JsonConvert.SerializeObject(booking,Formatting.Indented,
serializerSettings);
booking.CreatedBy = db.GetActiveUser();
var httpContent = new StringContent(json, Encoding.UTF8,
"application/json");
// AddAuthenicationHeader();
// Do the actual request and await the response
var httpResponse = await httpClient.PostAsync(Constants.BaseUrl + Constants.ApiSegmant + Constants.AddBooking, httpContent);
statusCode = httpResponse.StatusCode;
return statusCode;
}
As said before in my previous post its not giving me an error my Xamarin forms c# android application its just crashing at the JsonConvert line.
I have seen some articles suggesting turning off reference loop handling works but it doesn't in my case as I need to add the student at time of the booking.
How do I get more details error information on what is happening I tried adding.
On my booking class but it doesn't even get fired?. A try catch doesn't catch it either.
[OnError]
internal void OnError(StreamingContext context, ErrorContext errorContext)
{
var test = errorContext.Error;
}
I even tried [JsonIgnore] but i dont want that as I want the students to be with the bookings.
There is a self-referencing loop, as both models reference each other and if Json.NET was to serialise the object, it'd be stuck between Booking and Student.
Try ignoring the bookings from being serialised in every student using [JsonIgnore].
public class Student
{
public int Id { get; set; }
public int? Type { get; set; }
public string? FirstName { get; set; }
public string? Surname { get; set; }
public DateTime? DOB { get; set; }
public decimal? Weight { get; set; }
public decimal? Height { get; set; }
public int? Gender { get; set; }
public string? Photo { get; set; }
public int? Age { get; set; }
[JsonIgnore]
public ICollection<Booking> Bookings { get; set; }
public bool? IsDeleted { get; set; }
public ICollection<Notes>? Notes { get; set; }
public decimal? TB { get; set; }
public decimal? OP { get; set; }
public decimal? PU { get; set; }
public decimal? PB { get; set; }
public decimal? BP { get; set; }
public bool? IsActive { get; set; }
public string? CreatedBy { get; set; }
public string? LastModifiedBy { get; set; }
public DateTime? LastUpdatedDate { get; set; }
public DateTime? CreatedDate { get; set; }
}
Related
I have two tables, InHandOrder & ExpRegistry. These table have a common column OrderNo.
When I insert data into the ExpRegistry table, it checks if InHandOrder table's OrderNo is equal to ExpRegistry table's OrderNo; if so, some of the column will automatically save into InHandOrder table that particular row in which OrderNo is matches.
I have tried something but data didn't save into the particular row but it's added a new row and save the data.
ExpRegistry controller class:
[HttpPost]
[ProducesResponseType(StatusCodes.Status201Created)]
[ProducesResponseType(StatusCodes.Status202Accepted)]
[ProducesResponseType(StatusCodes.Status400BadRequest)]
[ProducesResponseType(StatusCodes.Status500InternalServerError)]
public IActionResult Create(ExpRegistry obj)
{
if (ModelState.IsValid)
{
_unitOfWork.ExpRegistry.Add(obj);
_unitOfWork.Save();
IEnumerable<InHandOrder> objInHandOrderList = _unitOfWork.InHandOrder.GetAll().ToList();
var checkOrderNo = objInHandOrderList.FirstOrDefault(i => i.OrderNo == obj.OrderNo);
_unitOfWork.InHandOrder.Add(new InHandOrder()
{
InvoiceNo = obj.InvoiceNo,
ShipQty = obj.ShipQty,
InvoiceValue = obj.InvoiceValue
});
_unitOfWork.Save();
return CreatedAtAction("GetDetails", new { id = obj.Id }, obj);
}
_logger.LogError($"Something went wrong in the {nameof(Create)}");
return StatusCode(500, "Internal Server Error, Please Try Again Later!");
}
InHandOrder model class:
public class InHandOrder
{
[Key()]
[DatabaseGenerated(DatabaseGeneratedOption.None)]
public int Id { get; set; }
// Purchase Order
public int? ContractListId { get; set; }
[ForeignKey("ContractListId")]
[ValidateNever]
public ContractList? ContractList { get; set; }
public string? OrderNo { get; set; }
public int? StyleListId { get; set; }
[ForeignKey("StyleListId")]
[ValidateNever]
public StyleList? StyleList { get; set; }
public int? SeasonListId { get; set; }
[ForeignKey("SeasonListId")]
[ValidateNever]
public SeasonList? SeasonList { get; set; }
public DateTime? Shipment { get; set; }
public int? TotalQuantity { get; set; }
public decimal? UnitPrice { get; set; }
public decimal? PoValue { get; set; }
public int? CountryListId { get; set; }
[ForeignKey("CountryListId")]
[ValidateNever]
public CountryList? CountryList { get; set; }
// Export Register
public string? InvoiceNo { get; set; }
public int? ShipQty { get; set; }
public decimal? InvoiceValue { get; set; }
public decimal? ShortValue { get; set; }
public int? ShortQty { get; set; }
}
Here, InvoiceNo, ShipQty, InvoiceValue, shortValue, ShortQty fields will be saved when ExpRegistry is saved.
ExpRegistry model class:
public class ExpRegistry
{
[Key]
public int Id { get; set; }
public int? PoId { get; set; }
[DisplayName("Exp No")]
public string? ExpNo { get; set; }
[DisplayName("UNIT")]
public int? UnitListId { get; set; }
[ForeignKey("UnitListId")]
[ValidateNever]
public UnitList? UnitList { get; set; }
[Display(Name = "DATE")] //EXP ISSUE DATE
[DataType(DataType.Date)]
[DisplayFormat(DataFormatString = "{0:dd-MM-yyyy}", ApplyFormatInEditMode = true)]
public DateTime? ExpIssueDate { get; set; }
[DisplayName("ORDER NO")]
[ValidateNever]
public string? OrderNo { get; set; }
[DisplayName("INVOICE NO")]
[ValidateNever]
public string? InvoiceNo { get; set; }
[DisplayName("SHIPPED QTY")]
[ValidateNever]
public int? ShipQty { get; set; }
[DisplayName("VALUE")]
[DisplayFormat(DataFormatString = "{0:C}", ApplyFormatInEditMode = false)]
[ValidateNever]
public decimal? InvoiceValue { get; set; }
}
Please Help me to solve the issue. Thank you.
I am trying to map multiple Userprofile models into a single viewModel. At a time only one user data will be mapped.
In the below code snippet I mentioned the use case that I already tried.
Also, I try to AutoMapper.Map<source,target> but didn't work for me.
//This is one FarmerUser Model
public partial class FarmerProfileModel
{
public long FarmerId { get; set; }
public string FarmerName { get; set; }
public string FatherHusbandName { get; set; }
public string Cnic { get; set; }
public string Gender { get; set; }
public string CellPhone { get; set; }
public string PresentAddress { get; set; }
public string PermanentAddress { get; set; }
public int? EducationCode { get; set; }
public int? MaleDependant { get; set; }
public int? FemaleDependant { get; set; }
public string AlternateName { get; set; }
public string AlternateCellPhoneNo { get; set; }
public string AlternateRelationshipwithFarmer { get; set; }
public int? ReferalCode { get; set; }
public string FarmerImage { get; set; }
public string UnionCouncil { get; set; }
public string MozaName { get; set; }
public int? SmallAnimals { get; set; }
public int? BigAnimals { get; set; }
public int? Tractor { get; set; }
public Guid? UserGuid { get; set; }
public DistrictCodeModel DistrictCodeNavigation { get; set; }
public TehsilCodeModel TehsilCodeNavigation { get; set; }
}
Another Model of the Tso User
public class TsoProfileModel
{
public long Tsoid { get; set; }
public string Tsoname { get; set; }
public string Cnic { get; set; }
public string Email { get; set; }
public string CellPhone { get; set; }
public string AlternateCellPhone { get; set; }
public string Landline { get; set; }
public string Gender { get; set; }
public string Tsoimage { get; set; }
public int? ModifiedBy { get; set; }
public DateTime? ModifiedDateTime { get; set; }
public DateTime? InsertionDate { get; set; }
public string ActiveStatus { get; set; }
public Guid? UserGuid { get; set; }
public TbDistrictCode DistrictCodeNavigation { get; set; }
public TbTehsilCode TehsilCodeNavigation { get; set; }
}
This is my ViewModel in which i am trying to incorporrate my data of Farmer/Tso
public class UserProfileInfo
{
public long? UserId { get; set; }
public string UserName { get; set; }
public string Cnic { get; set; }
public string Email { get; set; }
public string AlternateCellPhone { get; set; }
public string Landline { get; set; }
public string Gender { get; set; }
public string PresentAddress { get; set; }
public string PermanentAddress { get; set; }
public int? EducationCode { get; set; }
public string image { get; set; }
public int? ModifiedBy { get; set; }
public DateTime? ModifiedDateTime { get; set; }
public DateTime? InsertionDate { get; set; }
public string ActiveStatus { get; set; }
public Guid? UserGuid { get; set; }
public string FatherHusbandName { get; set; }
public string CellPhone { get; set; }
public int? MaleDependant { get; set; }
public int? FemaleDependant { get; set; }
public string AlternateName { get; set; }
public string AlternateRelationshipwithFarmer { get; set; }
public int? ReferalCode { get; set; }
public string UnionCouncil { get; set; }
public string MozaName { get; set; }
public int? SmallAnimals { get; set; }
public int? BigAnimals { get; set; }
public int? Tractor { get; set; }
public string Role { get; set; }
public DistrictCodeModel DistrictCodeNavigation { get; set; }
public TehsilCodeModel TehsilCodeNavigation { get; set; }
}
Below is the code I am trying to use.
if (User=="farmer")
{
var tbFarmerInfo = await
_farmerService.GetFarmerByCellPhone(cellno);
var result = _Mapper.Map<UserProfileInfo>(tbFarmerInfo);
result.UserId = tbFarmerInfo.FarmerId;
result.UserName = tbFarmerInfo.FarmerName;
result.image = tbFarmerInfo.FarmerImage;
result.Role = "Farmer";
response.Data = result;
return response;
}
else if (User == "TSO")
{
string cellno = User.Claims.FirstOrDefault(c => c.Type ==
ClaimTypes.Name).Value.TrimStart('0');
var tbTsoInfo = await _tsoService.GetTSOByCellPhone(cellno);
var result = _Mapper.Map<UserProfileInfo>(tbTsoInfo);
result.UserId = tbTsoInfo.Tsoid;
result.UserName = tbTsoInfo.Tsoname;
result.image = tbTsoInfo.Tsoimage;
result.Role = "TSO";
response.Data = result;
return response;
}
The expected result should be that both models can be mapped in the viewModel.
Like, if I map the FarmerProfile it should be mapped and if I want to map TsoProfile it should be mapped too.
At web API Dot net core
I have an action that GetById.
[HttpGet]
[Route("Get")]
public IActionResult Get(long ID)
{
ResultResponse oResultResponse = new ResultResponse();
IActionResult response;
try
{
ContractReleaseRequest result = service.GetByID( ID);
;
oResultResponse.Returned = result;
oResultResponse.IsSucceed = true;
oResultResponse.ErrorID = EnumServiceStatus.NoError;
}
catch (Exception e)
{
oResultResponse.IsSucceed = false;
oResultResponse.ErrorID = EnumServiceStatus.ExceptionError;
oResultResponse.ErrorMessage = e.Message;
}
response = this.Ok(oResultResponse);
return response;
}
and the model ContractReleaseRequest is.
public partial class ContractReleaseRequest
{
public ContractReleaseRequest()
{
ContractReleaseRequestTranslate = new HashSet<ContractReleaseRequestTranslate>();
RequestFile = new HashSet<RequestFile>();
}
public long ID { get; set; }
public string RequestNo { get; set; }
public long? DepartmentID { get; set; }
public string PurchaseOrderNumber { get; set; }
public DateTime? CreatedDate { get; set; }
public long? CreatedBy { get; set; }
public DateTime RequestDate { get; set; }
public bool IsSend { get; set; }
public DateTime? ModifiedDate { get; set; }
public long? ModifiedBy { get; set; }
public bool? IsDeleted { get; set; }
public Department Department { get; set; }
public Contract Contract { get; set; }
public virtual ICollection<ContractReleaseRequestTranslate> ContractReleaseRequestTranslate { get; set; }
public virtual ICollection<RequestFile> RequestFile { get; set; }
}
And the model is
using Trio.Contract.Data.Models;
[MapsFrom(typeof(Data.Models.ContractReleaseRequest), ReverseMap = true)]
public class ContractReleaseRequestModel
{
//public ContractReleaseRequestModel()
//{
// ContractReleaseRequestTranslate = new HashSet<ContractReleaseRequestTranslateModel>();
// RequestFile = new HashSet<RequestFileModel>();
//}
public long ID { get; set; }
public string RequestNo { get; set; }
public long? DepartmentID { get; set; }
public string PurchaseOrderNumber { get; set; }
public DateTime? CreatedDate { get; set; }
public long? CreatedBy { get; set; }
public DateTime? ModifiedDate { get; set; }
public long? ModifiedBy { get; set; }
public bool? IsDeleted { get; set; }
public DateTime RequestDate { get; set; }
public bool IsSend { get; set; }
[IgnoreMap]
//[IgnoreMapToAttribute(typeof(DepartmentModel))]
public DepartmentModel Department { get; set; }
public ContractModel Contract { get; set; }
public ICollection<ContractReleaseRequestTranslateModel> ContractReleaseRequestTranslate { get; set; }
public ICollection<RequestFileModel> RequestFile { get; set; }
}
when i call it from post man it return
Could not get any response
There was an error connecting to http://localhost/ContractApi/api/ContractReleaseRequest/Get?ID=1.
Why this might have happened:
The server couldn't send a response:Ensure that the backend is working properly
Self-signed SSL certificates are being blocked:
Fix this by turning off 'SSL certificate verification' in Settings > General
Proxy configured incorrectly Ensure that proxy is configured correctly in Settings > Proxy
Request timeout:
Change request timeout in Settings > General
when I searched I understand that this error because the main model contain another objects or models and, it cannot serialize them to JSON, But I don't know the solution.
Anyone help me??
I'm not sure if this is possible or not, but I thought I would ask...
I have two database tables. One is a list of users pulled from Active Directory. The second table is a list of scheduled forwards. The relationship I would like to create would be...
public class AdObject
{
[Key]
[DatabaseGenerated(DatabaseGeneratedOption.Identity)]
public int Id { get; set; }
public string ObjectType { get; set; }
public string FirstName { get; set; }
public string LastName { get; set; }
public string DisplayName { get; set; }
public string DistinguishedName { get; set; }
public string PrimaryEmail { get; set; }
public string Alias { get; set; }
public string SamAccountName { get; set; }
public string PrimaryDisplay { get; set; }
public string CanonicalName { get; set; }
public string OU { get; set; }
public string CoreGroup { get; set; }
public string ForwardedTo { get; set; }
public bool? IsDisabled { get; set; }
public bool? IsForwarded { get; set; }
public bool? DeliverAndRedirect { get; set; }
public bool? DisableForwardAtLogon { get; set; }
public DateTime? DisableAtLogonAfter { get; set; }
public string Notify { get; set; }
public DateTime? LastLogon { get; set; }
public DateTime? LastApiLogon { get; set; }
public DateTime? LastCheck { get; set; }
// This isn't required. But if possible I would like this to be
// a relationship to another AdObject whos "PrimaryEmail" matches
// the "ForwardedTo" column of this AdObject. There will not always
// be a match though, so not too important just wondering if its possible.
public AdObject ForwardedToObject { get; set; }
// This would be a list of forwards where the "ForwardFrom"
// column matches the "PrimaryEmail" of this AdObject.
public ICollection<Forward> ScheduledForwards { get; set; }
= new List<Forward>();
// FYI... Technically ID,SamAccountName,PrimaryEmail,DistinguishedName,
// and CanonicalName are all unique. They could all be keys.
}
public class Forward
{
[Key]
[DatabaseGenerated(DatabaseGeneratedOption.Identity)]
public int Id { get; set; }
public string ForwardFrom { get; set; }
public string ForwardTo { get; set; }
public bool? DeliverAndRedirect { get; set; }
public DateTime? StartTime { get; set; }
public DateTime? StopTime { get; set; }
public string Recurrence { get; set; }
public bool? DisableForwardAtLogon { get; set; }
public DateTime? DisableAtLogonAfter { get; set; }
public string Notify { get; set; }
public string StartJobId { get; set; }
public string StopJobId { get; set; }
public string StartJobStatus { get; set; }
public string StopJobStatus { get; set; }
public DateTime? StartJobCompleted { get; set; }
public DateTime? StopJobCompleted { get; set; }
public DateTime? StartJobCreated { get; set; }
public DateTime? StopJobCreated { get; set; }
public string StartReason { get; set; }
public string StopReason { get; set; }
// This would be the AdObject whos "PrimaryEmail" matches the
// "ForwardTo" column.
public AdObject ForwardToObject { get; set; }
// This would be the AdObject whos "PrimaryEmail" matches the
// "ForwardFrom" column.
public AdObject ForwardFromObject { get; set; }
}
I think I got it figured out. I was having a hell of a time understanding the logic behind relationships. I had a few misconceptions that I ironed out and after going through every YouTube video, PluralSight Course and Udemy course I could find it finally started to click. I usually don't have this much trouble teaching myself these things, but the misconceptions I had were pointing me in the wrong direction. In the end I only had to specify the keys and two relationships (conventions did the rest).
public class AdObject
{
[Key, Column(Order = 0)]
[DatabaseGenerated(DatabaseGeneratedOption.Identity)]
public int Id { get; set; }
public string ObjectType { get; set; }
public string FirstName { get; set; }
public string LastName { get; set; }
public string DisplayName { get; set; }
public string DistinguishedName { get; set; }
[Key, Column(Order = 1)]
public string PrimaryEmail { get; set; }
public string Alias { get; set; }
public string SamAccountName { get; set; }
public string PrimaryDisplay { get; set; }
public string CanonicalName { get; set; }
public string OU { get; set; }
public string CoreGroup { get; set; }
public bool? IsDisabled { get; set; }
public bool? IsForwarded { get; set; }
public bool? DeliverAndRedirect { get; set; }
public bool? DisableForwardAtLogon { get; set; }
public DateTime? DisableAtLogonAfter { get; set; }
public string Notify { get; set; }
public DateTime? LastLogon { get; set; }
public DateTime? LastApiLogon { get; set; }
public DateTime? LastCheck { get; set; }
public AdObject ForwardedToObject { get; set; }
public ICollection<Forward> ForwardRecipientSchedule { get; set; }
= new List<Forward>();
public ICollection<Forward> ForwardSchedule { get; set; }
= new List<Forward>();
}
public class Forward
{
[Key]
[DatabaseGenerated(DatabaseGeneratedOption.Identity)]
public int Id { get; set; }
public AdObject ForwardFromObject { get; set; }
public AdObject ForwardToObject { get; set; }
public bool? DeliverAndRedirect { get; set; }
public DateTime? StartTime { get; set; }
public DateTime? StopTime { get; set; }
public string Recurrence { get; set; }
public bool? DisableForwardAtLogon { get; set; }
public DateTime? DisableAtLogonAfter { get; set; }
public string Notify { get; set; }
public string StartJobId { get; set; }
public string StopJobId { get; set; }
public string StartJobStatus { get; set; }
public string StopJobStatus { get; set; }
public DateTime? StartJobCompleted { get; set; }
public DateTime? StopJobCompleted { get; set; }
public DateTime? StartJobCreated { get; set; }
public DateTime? StopJobCreated { get; set; }
public string StartReason { get; set; }
public string StopReason { get; set; }
}
public class EntityContext : DbContext
{
public EntityContext() : base("name=EnityContext"){
}
public DbSet<AdObject> AdObjects { get; set; }
public DbSet<Forward> Forwards { get; set; }
//protected override void OnConfiguring(DbContext)
protected override void OnModelCreating(DbModelBuilder modelBuilder)
{
modelBuilder.Entity<AdObject>()
.HasMany(f => f.ForwardSchedule)
.WithRequired(f => f.ForwardFromObject)
.WillCascadeOnDelete(false);
modelBuilder.Entity<AdObject>()
.HasMany(f => f.ForwardRecipientSchedule)
.WithRequired(f => f.ForwardToObject)
.WillCascadeOnDelete(false);
base.OnModelCreating(modelBuilder);
}
}
I am trying to force entity framework 5.0 to create a constructor on each of my generated poco classes. This constructor should instantiate any foreign key navigation properties I have.
e.g.
public partial class Event
{
public System.Guid EventId { get; set; }
public System.DateTime CreatedDate { get; set; }
public string CreatedUser { get; set; }
public int CreatedUserId { get; set; }
public string Title { get; set; }
public string EventDesc { get; set; }
public System.DateTime Start { get; set; }
public System.DateTime End { get; set; }
public string Source { get; set; }
public bool Editable { get; set; }
public string ClassName { get; set; }
public string Url { get; set; }
public bool IsDeleted { get; set; }
public bool IsObsolete { get; set; }
public bool AllDay { get; set; }
public System.DateTime ModifiedDate { get; set; }
public string ModifiedUser { get; set; }
public int RowVer { get; set; }
public virtual UserProfile UserProfile { get; set; }
}
should become:
public partial class Event
{
public Event()
{
this.UserProfile = new UserProfile();
}
public System.Guid EventId { get; set; }
public System.DateTime CreatedDate { get; set; }
public string CreatedUser { get; set; }
public int CreatedUserId { get; set; }
public string Title { get; set; }
public string EventDesc { get; set; }
public System.DateTime Start { get; set; }
public System.DateTime End { get; set; }
public string Source { get; set; }
public bool Editable { get; set; }
public string ClassName { get; set; }
public string Url { get; set; }
public bool IsDeleted { get; set; }
public bool IsObsolete { get; set; }
public bool AllDay { get; set; }
public System.DateTime ModifiedDate { get; set; }
public string ModifiedUser { get; set; }
public int RowVer { get; set; }
public virtual UserProfile UserProfile { get; set; }
}
I know it is possible, but not sure how. Any help would be most appreciated.
Thanks
When I retrieve from db in my repository (see below) I create a list of events, when I pass this list of events back via json I get a parse error due to event.UserProfile being null.
I could set it in code for each event, but that wouldn't be smart.
I need a link or an example if possible to help achieve what I need.
public List<Event> GetEvents(int userId, DateTime start, DateTime end)
{
List<Event> domainList = new List<Event>();
using (BookingModels dbEntities = new BookingModels())
{
var eventQuery = from dboEvents in dbEntities.Events
where dboEvents.Start >= start
&& dboEvents.End <= end
select dboEvents;
domainList = eventQuery.ToList<Event>();
}
return domainList;
}