'ArrayIndex'。
var result = uow.Repository<T_Tenant_Sub_PortalSetting>().Search(x => x.StudentPortalUrl.Split('/')[0].ToString() == filterContext.HttpContext.Request.Url.Host
&& (string.IsNullOrEmpty(x.StudentPortalUrl.Split('/')[1].ToString())) ? true : x.StudentPortalUrl.Split('/')[1].ToString() == WebConfigurationManager.AppSettings["VirtualDirectoryName"])
.IncludeEntity(x => x.T_Tenant_Sub).AsEnumerable().FirstOrDefault();
答案 0 :(得分:0)
//imagine this list is my entities IDbSet<...>
List<MyClass> myClasses = new List<MyClass>();
//you can read all entities {id,url} in RAM
Dictionary<int, string> keyValues =
new Dictionary<int, string>();
myClasses
.Where(x => true/*some conditions here*/)
.Select(x => new { x.Id, x.Url })
.ToList()//here data fetched from db
.ForEach(x => keyValues.Add(x.Id, x.Url));
//now you can use split
int[] SelectedIds = keyValues
.Where(x => x.Value.Split('/')[0] == "host"
/*&& another conditions here*/)
.Select(x=>x.Key)
.ToArray();
//now you can pass an array to db for fetching data
//as dbset
myClasses
.Where(x =>
SelectedIds.Contains(x.Id));
int[] SelectedIds = keyValues.Where(x => x.Value.Split('/')[0] == "host"/*&& another conditions here*/)
.Select(x=>x.Key)
.ToArray();
//now you can pass an array to db for fetching data
//as dbset
myClasses.Where(x => SelectedIds.Contains(x.Id));