0

I am trying to get Type variable from string

string queryableString = nameof(IQueryable) + "<" + entityType.FullName + " >";
Type type = Type.GetType(queryableString);

This works for any concrete class. But is returning null for IQueryable. Even the below returns null.

Type newType = typeof(SomeEntity).Assembly.GetType(nameof(IQueryable) + "<" + entityType.FullName + " >");
Type newType2 = Type.GetType(nameof(IQueryable) + "<" + entityType.FullName + " >" + "," + typeof(CaseHeader).Assembly.FullName);
Type newType3 = Type.GetType(nameof(IQueryable) + "<" + entityType.FullName + " >" + "," + typeof(IQueryable).Assembly.FullName);

Edit: as per the answer from duplicate mark

string queryableString = typeof(IQueryable).FullName + "`1[" + entityType.FullName + " ]"; /*+ "," + typeof(CaseHeader).Assembly.FullName;*/
var queryReturnType = queryableString.GetTypeFromString();

The string generated from above is

System.Linq.IQueryable`1[Sfc.Wms.Foundation.Data.Entities.CaseHeader ]

This does not work either

This is not working either

System.Linq.IQueryable`1[[Sfc.Wms.Foundation.Data.Entities.CaseHeader,Sfc.Wms.Foundation.Data, Version=1.0.0.0, Culture=neutral, PublicKeyToken=null ]]

0 Answers0