EntitySpace 常用语句

EntitySpace 这个是很早期的ORM框架,最近发现这个破解的也都不能用了。有谁知道能用的,联系我。

 

1. where带几个条件的 

query.Where(query.ProductTempStatus.Equal((int)tempStatus) | query.ProductStatus.Equal((int)status));

 query.Where(query.ProductTempStatus.Equal((int)tempStatus) && query.ProductStatus.Equal((int)status));

 

2. 批量更新的:

 

 public bool UpdateProductTempStatusBatch(List<int> productIds,ProductTempStatus status)
        {
            try
            {


                AwhProducts product = new AwhProducts();
                AwhProductsCollection products = new AwhProductsCollection();
                AwhProductsQuery query = new AwhProductsQuery();

 

                query.Where(query.ProductID.In(productIds));

                products.Load(query);

                foreach (var item in products)
                {
                    item.ProductTempStatus = (int)status;
                }

                products.Save();

                return true;

            }
            catch (Exception ex)
            {
                return false;
            }

        }

 

3. 使用事务

//MYSQL的事务语句无效

 using (esTransactionScope scope = new esTransactionScope())
 {

...

...

 product.Save();

brand.Save();

scope.Complete();

}

其它事务的用法:

 using (esTransactionScope noTrans = new esTransactionScope(esTransactionScopeOption.Suppress))

 using (esTransactionScope rootTrans2 = new esTransactionScope(esTransactionScopeOption.RequiresNew))

查看这里:

http://www.entityspaces.net/blog/CategoryView,category,Transactions.aspx

 

4.人工执行SQL语句

esUtility util = new esUtility();
int count = (int)util.ExecuteScalar(esQueryType.Text, "Select Count(*) From Employees");

 

 

posted on 2015-04-06 10:10  leegool  阅读(467)  评论(0编辑  收藏  举报

导航