RIA Service 从数据库取不到数据,但做插入操作是可以的?该如何处理
RIA Service 从数据库取不到数据,但做插入操作是可以的?
经调试,从DeepEarthDemo.Web.DomainService1 client = new DeepEarthDemo.Web.DomainService1() 这句代码发现client.WaterMeters 的Count值为0,估计是一条记录都没取到,难道没连上数据库吗?但我做插入操作是可以啊?初学RIA Service,好多不懂,请知道的帮小弟解决下,先谢谢了
------解决方案--------------------
这是silverlight特有的异步执行问题,你这样是去不到数据的,要加个PropertyChanged事件
------解决方案--------------------
一样纠结于此 PropertyChanged 事件里写你想要的操作..
- C# code
public void DrawLine() { DeepEarthDemo.Web.DomainService1 client = new DeepEarthDemo.Web.DomainService1(); DeepEarthDemo.Web.WaterMeter waterMeter = new DeepEarthDemo.Web.WaterMeter(); var sel = from s in client.WaterMeters where s.ID == 1 select s; if (sel.Count() == 0) return; DeepEarthDemo.Web.WaterMeter wm = sel.First(); string str = wm.PointList; MatchCollection matchs = Regex.Matches(str, @"\d+"); List<Point> points = new List<Point>(); for (int i = 0; i < matchs.Count; i += 2) { int x = Convert.ToInt32(matchs[i].Value); int y = Convert.ToInt32(matchs[i + 1].Value); Point p = new Point(x, y); pointList.Add(p); } AddLine(geoLayer, pointList); }
经调试,从DeepEarthDemo.Web.DomainService1 client = new DeepEarthDemo.Web.DomainService1() 这句代码发现client.WaterMeters 的Count值为0,估计是一条记录都没取到,难道没连上数据库吗?但我做插入操作是可以啊?初学RIA Service,好多不懂,请知道的帮小弟解决下,先谢谢了
------解决方案--------------------
这是silverlight特有的异步执行问题,你这样是去不到数据的,要加个PropertyChanged事件
------解决方案--------------------
一样纠结于此 PropertyChanged 事件里写你想要的操作..