public string[] GetCustomers(int count,string city) { var ctx = new LinqToSqlXml.DocumentContext("main"); var customers = ctx.GetCollection<Customer>().AsQueryable() .Where(c => c.Address.City == city) .Take(count) .AsJson(); return customers.ToArray(); }
public void SaveFromJson(string json) { var ctx = new LinqToSqlXml.DocumentContext("main"); ctx.GetCollection<Customer>().Add(json); ctx.SaveChanges(); }
public string GetObjectByName(string name) { var ctx = new LinqToSqlXml.DocumentContext("main"); var customer = ctx.GetCollection<Customer>().AsQueryable() .Where(c => c.Name == name) .AsJson() .First(); return customer; }
public void Save(Customer customer) { var ctx = new LinqToSqlXml.DocumentContext("main"); ctx.GetCollection<Customer>().Add(customer); ctx.SaveChanges(); }
public string GetObject(string id) { var gid = Guid.Parse(id); var ctx = new LinqToSqlXml.DocumentContext("main"); var customer = ctx.GetCollection<Customer>().AsQueryable() .Where(c => c.Id == gid) .Take(1) //first() is not yet implemented in the linq provider .AsJson() .ToList() .First(); return customer; }