vb.net - Entity framework - Return to list error? -
i got problem - return list
entity framework
. need return object. here code:
public function gethardwaredetail() list(of hardwaredetailapp) dim idlist new list(of string) dim data = (from p in db.tt_hardware select new hardwaredetailapp {.internalnum = p.internal_num, .description = p.description, .terminalmodel = p.hardware_model, .hardwareinternalnum = p.hardware_id, .status = p.isactive, .firmware = nothing, .serialnum = nothing}) if data.count > 0 each row in data idlist.add(row.internalnum) next end if dim data2 = (from p in db.tt_terminal_hardware idlist.contains(p.hardware_internal_num) select new hardwaredetailapp {.firmware = p.hardware_firmware, .serialnum = p.hardware_serial_num, .internalnum = data.firstordefault.internalnum, .description = data.firstordefault.description, .terminalmodel = data.firstordefault.terminalmodel, .hardwareinternalnum = data.firstordefault.hardwareinternalnum, .status = data.firstordefault.status}) return data2.tolist end function
this error get:
the type 'hardwaredetailapp' appears in 2 structurally incompatible initializations within single linq entities query. type can initialized in 2 places in same query, if same properties set in both places , properties set in same order.
in code, have created hardwaredetailapp
in 2 place, in every creation of must set same property same order.
for example if in linq entity
select
like:
place1: ... select new myclass() { propa: 1, } ...
and in query need select
myclass
other properties propb
, like:
place2: ... select new myclass() { propb: 2, } ...
you must change select
myclass
same, , set properties dont need them, default, , set properties in same order like:
place1: ... select new myclass() { propa: 1, propb: default(int), } ...
and
place2: ... select new myclass() { propa: default(int), propb: 2, } ...
my codes in c#
..
in part of code dim data = (from p in db.tt_hardw ....
try set firmware , serialnum
@ first second select
, (i have not checked other properties carefully)
Comments
Post a Comment