0

以下のようなlinqクエリがあります

using (RMPortalEntities _RMPortalEntities = new RMPortalEntities()) {

                var _RSVP_ButtonLocations = _RMPortalEntities
                                            .tbl_RSVP_ButtonLocation
                                            .Join(_RMPortalEntities.tbl_RSVP_Setting,
                                                            _RSVP_ButtonLocation => Guid.Parse(_RSVP_ButtonLocation.ID),
                                                            _RSVP_Setting => _RSVP_Setting.RSVP_Button_Location_ID,
                                                            (_RSVP_ButtonLocation, _RSVP_Setting) => new { _RSVP_ButtonLocation, _RSVP_Setting })
                                            .Join(_RMPortalEntities.tbl_Event,
                                                            _RSVP_ButtonLocation_RSVP_Setting => _RSVP_ButtonLocation_RSVP_Setting._RSVP_Setting.EventID,
                                                            _Event => _Event.ID,
                                                            (_RSVP_ButtonLocation_RSVP_Setting, _Event) => new { _RSVP_ButtonLocation_RSVP_Setting, _Event })
                                            .Where(x => x._Event.Active == true
                                                        && x._Event.ID == _EventID)
                                            .Select(x => new
                                            {

                                                RSVP_ButtonLocations = x._RSVP_ButtonLocation_RSVP_Setting._RSVP_ButtonLocation.RSVP_ButtonLocation

                                            });

                return _RSVP_ButtonLocations.FirstOrDefault().RSVP_ButtonLocations;
            }

しかし問題は、linq クエリでは文字列を Guid 値に変換できないことです。誰か私に提案をお願いできますか?

4

1 に答える 1

0

CjCoaxコメントに基づいて、GUIDのインスタンスを保存し、後でクエリで使用できます。

using (RMPortalEntities _RMPortalEntities = new RMPortalEntities()) {
            var GUID = new Guid(_RMPortalEntities.tbl_RSVP_ButtonLocation.ID);
            var _RSVP_ButtonLocations = _RMPortalEntities
                                        .tbl_RSVP_ButtonLocation
                                        .Join(_RMPortalEntities.tbl_RSVP_Setting,
                                                        _RSVP_ButtonLocation => GUID,
                                                        _RSVP_Setting => _RSVP_Setting.RSVP_Button_Location_ID,
                                                        (_RSVP_ButtonLocation, _RSVP_Setting) => new { _RSVP_ButtonLocation, _RSVP_Setting })
                                        .Join(_RMPortalEntities.tbl_Event,
                                                        _RSVP_ButtonLocation_RSVP_Setting => _RSVP_ButtonLocation_RSVP_Setting._RSVP_Setting.EventID,
                                                        _Event => _Event.ID,
                                                        (_RSVP_ButtonLocation_RSVP_Setting, _Event) => new { _RSVP_ButtonLocation_RSVP_Setting, _Event })
                                        .Where(x => x._Event.Active == true
                                                    && x._Event.ID == _EventID)
                                        .Select(x => new
                                        {

                                            RSVP_ButtonLocations = x._RSVP_ButtonLocation_RSVP_Setting._RSVP_ButtonLocation.RSVP_ButtonLocation

                                        });

            return _RSVP_ButtonLocations.FirstOrDefault().RSVP_ButtonLocations;
        }
于 2012-11-19T04:05:45.027 に答える