how can I use Moles to redirect select from tables via LINQ?

浪子不回头ぞ 提交于 2019-12-05 21:21:41

Looks like I was doing this completely wrong. This is the correct approach:

// using System.Data.Linq.Moles; 
// CM is a namespace alias 
var subsList = new List<CM.Subscription>{
  new CM.Subscription() { SubscriptionID = subId1 },
  new CM.Subscription() { SubscriptionID = subId2 },
  new CM.Subscription() { SubscriptionID = subId3 }};

var subsTable = new MTable<CM.Subscription>();

subsTable.Bind(subsList.AsQueryable());

MTheDataContext.AllInstances.SubscriptionGet = (c) => { return subsTable; };

With this code, any selection from the Subscriptions table will return these three records only.

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!