Optional Parameters in EntityFrameWork query

c#-4.0 entity-framework-6 optional-parameters

Question

The following are the signatures of my methods. All three of the other parameters are optional; only Id is required. I must address this in the where clause. If the optional ones are present, I must include them in the where clause; otherwise, the query should be constructed using the Id and any available optional parameters.

Second, can we compare using rowVersion as given in the following query? (In SQL Server, rowVersion is a time stamp)

GetRecords(int  Id, int[] LocationId = null, int PayrollNo = 0, byte[] rowVersion=null)

 {

     var result = this.context.employees.where(x=>x.Id == id && LocationId.Contains(x.locationId) && x.payrollNo ==PayrollNo && x.rowVersion >  rowVersion);

}

Any assistance would be much appreciated.

1
0
6/27/2015 7:55:15 PM

Popular Answer

ZZZ_tmp
1
6/28/2015 12:03:55 AM


Related Questions





Related

Licensed under: CC-BY-SA with attribution
Not affiliated with Stack Overflow
Licensed under: CC-BY-SA with attribution
Not affiliated with Stack Overflow