2010-08-21 4 views
1

내가 문제는 (음속)

IQueryable<Dealer> dealers = 
    from dealer in Dealers 
    join address in AddressesUS on dealer.DealerId equals address.OwnerId 
    where dealer.Country == country && address.Owner == (int)Contact.OwnerType.Dealer 
    select new Dealer() 
    { 
     DealerId = dealer.DealerId, 
     DealerName = dealer.DealerName, 
     Country = dealer.Country, 
     Email = dealer.Email, 
     Contact = dealer.Contact, 
     Url = dealer.Url, 
     IsActive = dealer.IsActive, 
     IsWholesale = dealer.IsWholesale, 
     Address = address == null ? null : address 
    }; 

내가 그것을 실행 코드

이 슬라이스가 (ToArray 또는 무엇이든을 호출하여)에 참여,이 오류가 발생합니다. String 'to'***. Model.Address '

이제 Dealer.Address를 type 문자열로 변경하면 실제로 AddressUS : Address 유형이어야하므로 코드가 컴파일되지 않습니다. 그러나 Dealer.Address의 유형을 객체로 변경하고 코드를 실행하면 SubSonic에 DB의 첫 번째 문자열 열이 채워진 것을 볼 수 있습니다. I.E. dealer.Address = "123 Fake St." 딜러와 주소에 대한 DB에는 아무런 관련이 없으므로 차이가 있는지 확실하지 않습니다.

내가 닷넷 3.5 여기

MySQL의 5를 사용하고이 스택 트레이스

at System.Convert.DefaultToType(IConvertible value, Type targetType, IFormatProvider provider) 
    at System.String.System.IConvertible.ToType(Type type, IFormatProvider provider) 
    at System.Convert.ChangeType(Object value, Type conversionType, IFormatProvider provider) 
    at System.Convert.ChangeType(Object value, Type conversionType) 
    at SubSonic.Extensions.Objects.ChangeTypeTo(Object value, Type conversionType) 
    at SubSonic.Extensions.Database.Load[T](IDataReader rdr, T item, List`1 ColumnNames) 
    at SubSonic.Extensions.Database.ToEnumerable[T](IDataReader rdr, List`1 ColumnNames) 
    at SubSonic.Linq.Structure.DbQueryProvider.Execute[T](QueryCommand`1 query, Object[] paramValues) 
    at lambda_method(ExecutionScope) 
    at SubSonic.Linq.Structure.DbQueryProvider.Execute(Expression expression) 
    at SubSonic.Linq.Structure.QueryProvider.System.Linq.IQueryProvider.Execute(Expression expression) 
    at SubSonic.Linq.Structure.Query`1.GetEnumerator() 
    at System.Linq.Buffer`1..ctor(IEnumerable`1 source) 
    at System.Linq.Enumerable.ToArray[TSource](IEnumerable`1 source) 
    at InSite.Controllers.DealerController.GetDealers() in ***Controllers\DealerController.cs:line 25 
    at lambda_method(ExecutionScope , ControllerBase , Object[]) 
    at System.Web.Mvc.ActionMethodDispatcher.Execute(ControllerBase controller, Object[] parameters) 
    at System.Web.Mvc.ReflectedActionDescriptor.Execute(ControllerContext controllerContext, IDictionary`2 parameters) 
    at System.Web.Mvc.ControllerActionInvoker.InvokeActionMethod(ControllerContext controllerContext, ActionDescriptor actionDescriptor, IDictionary`2 parameters) 
    at System.Web.Mvc.ControllerActionInvoker.<>c__DisplayClassd.<InvokeActionMethodWithFilters>b__a() 
    at System.Web.Mvc.ControllerActionInvoker.InvokeActionMethodFilter(IActionFilter filter, ActionExecutingContext preContext, Func`1 continuation) 
+0

어떻게'address == null입니까? null : 주소'가 단지'주소'와 다른가요? – Gabe

+0

그것은 주소가 아닌 주소 == null을하려고 할 때부터 남은 코드입니다. null : new AddressUS {...} – Peijen

답변

0

음속의 버그가있어입니다 ... 자세한 내용은이 Linq and SubSonic - returning nested complex types를 참조하십시오.

대리점 대신 익명 형식을 반환하거나 Select 투영 전에 ToList()를 호출하여 동일한 문제인지 확인할 수 있습니다. 그러한 경우에 작동하면 동일한 버그입니다.

+0

네, 익명의 타입을 사용할 때 확실히 작동합니다. 나는 그것이 버그라고 확신했다. 불행하게도 나는 데드 라인이있다. 그렇지 않으면 나는 소스 코드를 다운로드하고 그것을 고칠 수 있는지를 보았다. – Peijen

+0

github http://github.com/subsonic/SubSonic-3.0/issues에 이미 로그인되어있는 경우이를 문제로 기록하거나 세부 정보를 추가 할 수 있습니까? –