This thread looks to be a little on the old side and therefore may no longer be relevant. Please see if there is a newer thread on the subject and ensure you're using the most recent build of any software if your question regards a particular product.
This thread has been locked and is no longer accepting new posts, if you have a question regarding this topic please email us at support@mindscape.co.nz
|
Hello I am having problems with a Linq query. I am not sure if it's something I have overlooked or something LightSpeed doesn't like. I need to return an ID field which is of type GUID (c.Id) along with other fields of type String. var results = (from c in uow.Contacts orderby c.LastName ascending, c.FirstName ascending select new {ID=c.Id, Title = c.Title, LastName=c.LastName, FirstName=c.FirstName, Email=c.ContactEmailAddresses[0].Email }).Take(2);
{ ... } [/CODE] public class ContactResult { public Guid ID; public String Title; public String LastName; public String FirstName; public String Email; } [/CODE] var results = (from c in uow.Contacts orderby c.LastName ascending, c.FirstName ascending select new ContactResult(){ID=c.Id, Title = c.Title, LastName=c.LastName, FirstName=c.FirstName, Email=c.ContactEmailAddresses[0].Email }).Take(2);
{ ... } [/CODE] [InvalidCastException: Invalid cast from 'System.String' to 'System.Guid'.] System.Convert.DefaultToType(IConvertible value, Type targetType, IFormatProvider provider) +7569852 System.String.System.IConvertible.ToType(Type type, IFormatProvider provider) +8 System.Convert.ChangeType(Object value, Type conversionType, IFormatProvider provider) +7601872 Mindscape.LightSpeed.Linq.Utils.TypeHelper.NullableSafeConvert(Object value, Type targetType) +245 Mindscape.LightSpeed.Linq.ProjectedTypeBuilder.GetValue(Int32 expressionIndex, IDataRecord record, Type targetType) +173 Mindscape.LightSpeed.Linq.NamedTypeBuilder.InitialiseMembersFromReader(MemberInitExpression memberInit, IDataRecord record, Object instance) +476 Mindscape.LightSpeed.Linq.NamedTypeBuilder.Build(IDataRecord record) +103 Mindscape.LightSpeed.Linq.Plan.SingleQueryPlan.ProjectNative(IUnitOfWork unitOfWork) +223 Mindscape.LightSpeed.Linq.Plan.SingleQueryPlan.ExecuteImmediate(IUnitOfWork unitOfWork, Type returnType) +1580 Mindscape.LightSpeed.Linq.LinqQueryProvider.Execute(Expression expression) +237 Mindscape.LightSpeed.Linq.LinqQueryProvider.System.Linq.IQueryProvider.Execute(Expression expression) +37 Mindscape.LightSpeed.Linq.LinqQuery`1.GetEnumerator() +40 [/CODE] |
|
|
Thanks for drawing this to our attention. This was a bug. It is now fixed and the fix will be included in the 26 Mar 2010 nightly build, available from about 1500 GMT. |
|
|
Thanks for the quick response and fix much appreciated ;) |
|