English 中文(简体)
实体数据模型,动态林克,多种表格动态 在条款中,严格分类的回归类型
原标题:Entity Data Model, Dynamic Linq, multiple table dynamic Where clause, strongly typed return types

在撰写网上数据服务方法时,我有以下的linq,为此,我需要一个动态的“地方”条款来筛选结果(合并中的“新”是指实体数据模型中的复合PK):

var query = from pl in CurrentDataSource.ProductListing
             join pla in CurrentDataSource.ProductListingAttribute
                 on new {pl.ProductID, pl.WebCategoryID, pl.ParentProductID}
                 equals new {pla.ProductID, pla.WebCategoryID, pla.ParentProductID}
             join att in CurrentDataSource.Attribute
                 on pla.AttributeID
                 equals att.AttributeID
             join attItem in CurrentDataSource.AttributeItem
                 on pla.AttributeItemID
                 equals attItem.AttributeItemID
             select pl;

我的林克并不好,I m试图利用具有活力的贱民阶级在经营时产生“其他地方”条款(从各种变量中形成):

var returnData = query.Where(whereClause);

由于“哪里”条款过滤了阿特林特和阿特林特姆实体的数值,因此它始终包含类似的东西。

"((Attribute.Value= foo  AND AttributeItem.Value= bar ) 
OR 
(Attribute.Value= sna  AND AttributeItem.Value= fu ))"

由于“在产品类型中不存在任何不动产或田间补贴”而出现故障。

我曾试图在“选择”中建立一个匿名的类型,其中含有产品销售实体的所有要素,以及我要求过滤的Attribute和AtributeItem的所有要素,但我需要一个高度类型的实体,即“促进”从这一方法中返回。

Can ANY 请帮助? 我是否应该利用充满活力的儒昂,而不是充满活力的地方? 是否有办法打击那些不再选择的实体? 我是否应该选择匿名型/“莱特”和随后建立强烈分类的实体?

请提供任何帮助。

rposa

问题回答

我特别询问的解决办法是:

            var query = from pl in CurrentDataSource.ProductListing
                             join pla in CurrentDataSource.ProductListingAttribute
                                 on new {pl.ProductID, pl.WebCategoryID, pl.ParentProductID}
                                 equals new {pla.ProductID, pla.WebCategoryID, pla.ParentProductID}
                             join att in CurrentDataSource.Attribute
                                 on pla.AttributeID
                                 equals att.AttributeID
                             join attItem in CurrentDataSource.AttributeItem
                                 on pla.AttributeItemID
                                 equals attItem.AttributeItemID
                        select new
                        {
                            ProductListing = pl,
                            att.AttributeName,
                            attItem.AttributeValue
                        };

            var returnData = query.Where(whereClause).Select(o => o.ProductListing);

i. 选择含有具体类型的匿名类型,在什么地方适用条款,然后只从结果中选择具体类型。





相关问题
Anyone feel like passing it forward?

I m the only developer in my company, and am getting along well as an autodidact, but I know I m missing out on the education one gets from working with and having code reviewed by more senior devs. ...

NSArray s, Primitive types and Boxing Oh My!

I m pretty new to the Objective-C world and I have a long history with .net/C# so naturally I m inclined to use my C# wits. Now here s the question: I feel really inclined to create some type of ...

C# Marshal / Pinvoke CBitmap?

I cannot figure out how to marshal a C++ CBitmap to a C# Bitmap or Image class. My import looks like this: [DllImport(@"test.dll", CharSet = CharSet.Unicode)] public static extern IntPtr ...

How to Use Ghostscript DLL to convert PDF to PDF/A

How to user GhostScript DLL to convert PDF to PDF/A. I know I kind of have to call the exported function of gsdll32.dll whose name is gsapi_init_with_args, but how do i pass the right arguments? BTW, ...

Linqy no matchy

Maybe it s something I m doing wrong. I m just learning Linq because I m bored. And so far so good. I made a little program and it basically just outputs all matches (foreach) into a label control. ...

热门标签